简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM