Ben Mayo
Ben Mayo

Reputation: 1325

File missing from java.library.path

I am building an app to get NMEA GPS data, with serial port communication via RXTX. On my Mac it runs great. When I try to run it on my Rasp Pi, it throws the error:

no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver

On the Mac, I see that if I move /Library/Java/Extensions/librxtxSerial.jnilib it too throws the same error.

My question is: On my RasbPi, do I need to add this rxtxSerial file somewhere to a folder (perhaps within the JVM?), or should it be packaged up with the runnable jar when I export. Is my problem on my Mac, or on my RasbPi?

Thanks

Upvotes: 0

Views: 3511

Answers (2)

Markus Schulz
Markus Schulz

Reputation: 31

You can install this library on the Raspberry Pi via the normal package installation method.

Just type:

sudo apt-get install librxtx-java

Now you can start the jar like this:

java -Djava.library.path=/usr/lib/jni -cp /usr/share/java/RXTXcomm.jar -jar your.jar

Upvotes: 3

Jesper
Jesper

Reputation: 206926

The error means that a native library named rxtxSerial cannot be found. You need to have a native library for the Raspberry Pi with that name, and set the system property java.library.path so that it points to the directory that contains the native library. That means you have to start your Java program with the -D option, for example:

java -Djava.library.path=/some/dir com.mypackage.MyProgram

where /some/dir is the directory that contains the native library.

You'll have to find out if there is a native library that is suitable for the Raspberry Pi for the RXTX library that you are trying to use.

Upvotes: 0

Related Questions