1

I have to write a program in Java that will display all the COM ports I have on my computer. I'm using the RXTX.Comm library.

I imported it, and while writing the code, the program did not show any errors, but after the compilation in the console showed:

java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
Exception in thread "main" java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:83)
    at javaapplication14.JavaApplication14.listPorts(JavaApplication14.java:19)
    at javaapplication14.JavaApplication14.main(JavaApplication14.java:46)  

I do not know what's wrong with this error, I have 4 COM ports on my computer that should be displayed.

Euro Micelli
  • 33,285
  • 8
  • 51
  • 70

1 Answers1

0

The java serial library needs a 'native' component in order to run. On windows this is a .dll, on Linux this is a .so. This native library must be in the path of the executable to be found automatically.

If you now the location and don't want to edit the PATH environment variable you could also use -Djava.library.path JVM variable to point to the directory containing the native library.

M. le Rutte
  • 3,525
  • 3
  • 18
  • 31
  • Thank you for the reply, but unfortunately despite the addition still does not work –  Oct 12 '17 at 14:18