Hi im trying to read com port, so I add library to my java directory like
they wrote here but when Im witing simple code like
import java.util.Enumeration;
import javax.comm.*;
public class CompotCore {
public static void main(String[] args)
{
Enumeration list = CommPortIdentifier.getPortIdentifiers();
}
}
I get such error:
java.lang.UnsatisfiedLinkError: no Serial in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at gnu.io.RXTXCommDriver.<clinit>(RXTXCommDriver.java)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at javax.comm.CommPortIdentifier.loadDriver(CommPortIdentifier.java:237)
at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:109)
at CompotCore.main(CompotCore.java:11)
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.sun.comm.SunrayInfo.isSessionActive()Z
at com.sun.comm.SunrayInfo.isSessionActive(Native Method)
at com.sun.comm.Portmapping.registerCommPorts(Portmapping.java:155)
at com.sun.comm.Portmapping.refreshPortDatabase(Portmapping.java:100)
at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:138)
at CompotCore.main(CompotCore.java:11)
i read that I had to add System.load("Serial"); with full path but I dont have such library and dont know where to find it.
On the site you link to it includes instructions to copy two native libraries into your JRE lib dir:
Are they there?
Be sure you are copying them into the correct JRE. What does
which javatell you?An alternative to copying to jre/lib would be to have them in some other location and then point to that dir with the System Property
java.library.path, e.g. you would execute Java like this to start your programjava -Djava.library.path=<dir_with_those_libs> <your_other_args>Update
OK I downloaded the rtxt tar and took a look. After you untar it, you have the following (one example):
If you followed the instructions from that page, you will have only copied the links, not the actual libs. So the solution will be to copy ALL the files, something like this:
Or alternatively to execute Java something like: