0

I have to send data to serial port, javax.comm is also included but it gives the error "Caught java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path while loading driver gnu.io.RXTXCommDriver Error loading SolarisSerial: java.lang.UnsatisfiedLinkError: no SolarisSerialParallel in java.library.path Caught java.lang.UnsatisfiedLinkError: com.sun.comm.SolarisDriver.readRegistrySerial(Ljava/util/Vector;Ljava/lang/String;)I while loading driver com.sun.comm.SolarisDriver"

I visited all serial port data read write related question in stackoverflow but find no any solution

you kindly help me

the code is below:

package serial;
import java.io.*;
import java.util.*;
import javax.comm.SerialPort;
import javax.comm.CommPortIdentifier;
import javax.comm.UnsupportedCommOperationException;
import javax.comm.PortInUseException;

public class SimpleWrite {
static Enumeration portList;
static CommPortIdentifier portId;
static String messageString = "Hello, world!\n";
static SerialPort serialPort;
static OutputStream outputStream;

public static void main(String[] args) {
    portList = CommPortIdentifier.getPortIdentifiers();

    while (portList.hasMoreElements()) {
        portId = (CommPortIdentifier) portList.nextElement();
        if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
             if (portId.getName().equals("COM6")) {
            //if (portId.getName().equals("/dev/term/a")) {
                try {
                    serialPort = (SerialPort)
                        portId.open("SimpleWriteApp", 2000);
                } catch (PortInUseException e) {}
                try {
                    outputStream = serialPort.getOutputStream();
                } catch (IOException e) {}
                try {
                    serialPort.setSerialPortParams(9600,
                        SerialPort.DATABITS_8,
                        SerialPort.STOPBITS_1,
                        SerialPort.PARITY_NONE);
                } catch (UnsupportedCommOperationException e) {}
                try {
                    outputStream.write(messageString.getBytes());
                } catch (IOException e) {}
            }
        }
    }
}

}

user207421
  • 305,947
  • 44
  • 307
  • 483

1 Answers1

1

Ensure the library path of the serial library has been set. Try this

java -Djava.library.path=C:\java_comm\lib SimpleWrite 

You appear to be running a 32 bit version of Netbeans and (by extension) Java. Therefore ensure that you have a corresponding 32bit version of rxtxserial, can be found here

Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • Now placed the project folder into C:\java_comm\lib folder but error is same , kindly help, I know you are very busy but a few moments you give men i highly appreciate – Khalid Hussain Feb 14 '14 at 23:18
  • Are you using a 32bit `rxtxSerial.dll` (seems like you're using a 32bit NetBeans + JDK)? – Reimeus Feb 14 '14 at 23:25
  • Sir you give your email address, i send you file, you check it whether it is 32 bit or not i downloaded it and added into library, there is no any information mentioned in this library about 32 or 64 bit – Khalid Hussain Feb 14 '14 at 23:32
  • That's not how `SO` works. This is a Q&A site. Now back to library - there's no easy way to check the libraries so the quickest way is just to re-download the appropriate libraries - see the link added – Reimeus Feb 14 '14 at 23:41
  • I downloaded it after a lot of struggles, you send me link please/ – Khalid Hussain Feb 14 '14 at 23:47