0

I am a high school student working on a java application that communicates with an Arduino micro-controller vie USB. I'm using NetBeans IDE and the RXTX serial communication library.

Following RXTX install instructions I found online, I just right clicked on the libraries package in the navigator window on the left hand side and selected "Add Jar/Folder" selecting the RXTXcomm.jar. I then proceeded to code my program that opens serial port input and output streams. It worked perfectly inside the IDE test environment.

However, when I go to build my project, it builds properly, and upon running the executable jar file via a batch file, I get the following error:

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

I believe it is referencing the rxtxserial.dll. I looked up solutions to this and none of them have worked. Other questions I have found show possible solutions but none of these have worked, and any similar questions I have found have been for installing rxtx for the java runtime instead of a specific application. So far I have tried packaging it as a fat jar, I have tried adding the dll to the classpath through VM options, nothing seems to work. Can anyone help me here?

  • http://stackoverflow.com/questions/1403788/java-lang-unsatisfiedlinkerror-no-dll-in-java-library-path – Samuel Tulach Mar 13 '17 at 14:27
  • Possible duplicate of [java.lang.UnsatisfiedLinkError no \*\*\*\*\*.dll in java.library.path](http://stackoverflow.com/questions/1403788/java-lang-unsatisfiedlinkerror-no-dll-in-java-library-path) – madhan kumar Mar 13 '17 at 14:31
  • Did you try to put the DLL file in the same folder of your JAR application (and, obviously, use the folder as the working directory)? – sandromark78 Mar 13 '17 at 15:07
  • It isn't a duplicate, because mine has to do with a self contained application, while the question you are referencing involves installing rxtx for the entire java runtime. – Zachariah Phillips Mar 13 '17 at 15:13
  • Yes I have tried putting it in the same folder and I got the same error. – Zachariah Phillips Mar 13 '17 at 15:14

1 Answers1

0

The setup below works in my test:

-folder1
   -runprog.bat
   -rxtxSerial.dll
   -folder2
      -aaa.jar
      -lib
         -RXTXcomm.jar  

And the contents of my runprog.bat:

java -jar folder2\aaa.jar

Be sure to use the correct(32bit or 64bit) rxtxSerial.dll file. I have multiple java installations in my computer. When running through the IDE, I'm using the 32-bit rxtxSerial. While the setup above requires me to use the 64bit version of rxtxSerial.dll.

d_air
  • 631
  • 1
  • 4
  • 12