Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add rxtxSerial in java.library.path? [duplicate]

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

like image 465
Aditya Ponkshe Avatar asked Feb 19 '13 08:02

Aditya Ponkshe


People also ask

How to add rxtxSerial in Java library path?

Go to Project -> properties -> Java build path ->Find your . jar. Click on + to open the JAR's properties. Select Native library location and edit it to point to RXTX's shared library (.

What is Java lang UnsatisfiedLinkError?

lang. UnsatisfiedLinkError runtime error. More specifically, this error is thrown whenever the JVM is unable to find an appropriate native-language definition of a method declared native , while attempting to resolve the native libraries at runtime [2]. The UnsatisfiedLinkError error is a subclass of the java.

What is RXTX library?

RXTX is a Java native library providing serial and parallel communication for the Java Development Toolkit (JDK). RXTX is licensed under the GNU LGPL license as well as these binary distributions. RXTX is a great package, but it was lacking pre-built binaries for x64 (64-bit) versions of Windows.


2 Answers

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).

like image 129
martijno Avatar answered Sep 28 '22 00:09

martijno


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
like image 45
kevind7 Avatar answered Sep 28 '22 01:09

kevind7