I've had been using JSSC Connector for serial and I got the Next Exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no libjssc in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at jssc.SerialNativeInterface.<clinit>(SerialNativeInterface.java:34)
at jssc.SerialPort.<init>(SerialPort.java:93)
at cl.raien.jssc.SerialExample.main(SerialExample.java:22)
The Code:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jssc.SerialPort;
import jssc.SerialPortException;
public class SerialExample {
static Logger log = LoggerFactory.getLogger(SerialExample.class);
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
log.info(System.getProperty("java.library.path"));
SerialPort serialPort = new SerialPort("ttyUSB0");
try {
System.out.println("Port opened: " + serialPort.openPort());
System.out.println("Params setted: " + serialPort.setParams(9600, 8, 1, 0));
System.out.println("\"Hello World!!!\" successfully writen to port: " + serialPort.writeBytes("Hello World!!!".getBytes()));
System.out.println("Port closed: " + serialPort.closePort());
}
catch (SerialPortException ex){
System.out.println(ex);
}
}
}
I'm using ubuntu 12.10 86x_64 and de jssc install the $HOME/.jssc/linux/libjSSC-0.9_x86_64.so
In Eclipse I setted in the Native Library Location of jssc.jar to point to that directory first. Then, I putted that file in the project root folder, as says scream3r.org. Finally, I changed the name of the file to libjssc and libjssc.so.
Thanks in advance!!