Hairi Hairi - 9 months ago 92
Java Question

Java-simple-serial-connector trows exception 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");
//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(
at Main.main(

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 Source
  1. Download the JSSC zip here:
  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