12

I am developing an application in Java using Eclipse IDE. My os is Ubuntu 11. My application is using the RXTX library (gnu.io.*) for serial communication. I have added the RXTXomm.jar file in project by doing this (project->Properties->java buld path->add external jars). whenever I run my code it gives me this 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 even tried installing librxtx-java.deb. but it did not fix the problem. I searched around in file system and found that librxtxSerial.so is located in /usr/lib/jni.

How can I fix this issue?

Thanks in advance

Aditya Ponkshe
  • 3,840
  • 4
  • 39
  • 58

3 Answers3

16

Find your jar in Project -> properties -> Java build path. Click on the + to open the JAR's properties, select Native library location and edit it to point to RXTX's shared library (.DLL, .so, .dylib).

martijno
  • 1,723
  • 1
  • 23
  • 53
  • 3
    How would you do this in Netbeans ? – DevilCode Jul 14 '13 at 19:42
  • 2
    I don't know, I'm not a Net beans user. Search SO, Google, ... If that doesn't answer it, make it a new question (instead of a comment). – martijno Jul 16 '13 at 20:47
  • Awesome man... It is woking fine in linux... Upvote – Learner Jun 09 '14 at 10:01
  • Hi, I also getting same problem, but I am not understanding how can I open jar properties, because i did not found a option + in eclipse project build path please help me out to reslove same problem – Lina Dec 27 '16 at 10:03
2

One method is to set java.library.path in the Eclipse Run Configuration for your project. You can edit VM arguments in the Arguments tab of your Run Configuration (a couple of ways to access this include right click on project->Run As->Run Configurations... and Run menu->Run Configurations...).

If you create a lib directory in the root of your project and place a copy of the RXTX library in the lib directory you could use the following VM argument (substituting ProjName with the name of your project).

-Djava.library.path=${project_loc:ProjName}/lib
kevind7
  • 46
  • 1
  • 5
  • Edited to add some options to get to the Run Configuration for your project. The answer by @martijno gives a quicker and cleaner result but I sometimes prefer this way because it makes things more visible, particularly when pulling in multiple dependencies. – kevind7 Feb 19 '13 at 09:05
2

Open Terminal(Ctrl+Alt+T) and check :

echo $JAVA_HOME 
 # JDKDIR : /usr/lib/jvm/java-7-oracle

then run :

sudo cp /usr/lib/jni/librxtxSerial.so $JAVA_HOME/jre/lib/i386/
Abdennour TOUMI
  • 87,526
  • 38
  • 249
  • 254