Hairi Hairi - 15 days ago 12
Java Question

Java-simple-serial-connector trows exeption UnsatisfiedLinkError

I downloaded the sources from here. This is the code with wich I am trying to open com port 13.

I saw in the device menager that com port13 is present.

import jssc.*;

public class Main {
static boolean s = false;
public static void main(String[] args) {
// TODO Auto-generated method stub
SerialPort ser = new SerialPort("COM1");
try {
s = ser.openPort();
} catch (SerialPortException e) {
// TODO Auto-generated catch block
System.out.println("Riko Stana neshto");
//e.printStackTrace();
}
//System.out.println("Riko" + ser.getPortName() );
}
}


When ran in Eclipse this appears in the console:


Exception in thread "main" java.lang.UnsatisfiedLinkError: jssc.SerialNativeInterface.openPort(Ljava/lang/String;Z)J

at jssc.SerialNativeInterface.openPort(Native Method)
at jssc.SerialPort.openPort(SerialPort.java:158)
at Main.main(Main.java:9)


The linbrary consist of java files and two dll file. I linked the java files to my eclipse project, but not sure how they are linked to the dll files. Should I do something in order to link the .java files to the .dll files? Could it be the cause of my problem? Any help is very much appreciated.

Answer
  1. Download the JSSC zip here: https://code.google.com/archive/p/java-simple-serial-connector/downloads
  2. Extract jssc.jar in your project folder.
  3. Add the "jssc.jar" to your classpath as a .jar library.
  4. Optional: Extract javadoc/jssc-2.7.0-javadoc.jar and javadoc/jssc-2.7.0-src.jar in your project folder and add them as javadoc and sources respectively.

Problem solved.

Edit - pitcure: 1

Comments