简体   繁体   English

java.library.path中缺少文件

[英]File missing from java.library.path

I am building an app to get NMEA GPS data, with serial port communication via RXTX. 我正在构建一个通过RXTX通过串行端口通信获取NMEA GPS数据的应用程序。 On my Mac it runs great. 在我的Mac上,它运行良好。 When I try to run it on my Rasp Pi, it throws the error: 当我尝试在Rasp Pi上运行它时,会引发错误:

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. 在Mac上,我看到如果我移动/Library/Java/Extensions/librxtxSerial.jnilib,它也会引发相同的错误。

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. 我的问题是:在我的RasbPi上,我是否需要将此rxtxSerial文件添加到某个文件夹中(也许在JVM中?),或者在导出时将其与可运行的jar打包在一起。 Is my problem on my Mac, or on my RasbPi? 是Mac还是RasbPi出现问题?

Thanks 谢谢

You can install this library on the Raspberry Pi via the normal package installation method. 您可以通过常规的软件包安装方法在Raspberry Pi上安装此库。

Just type: 只需输入:

sudo apt-get install librxtx-java

Now you can start the jar like this: 现在您可以像这样启动jar了:

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. 该错误意味着找不到名为rxtxSerial的本地库。 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. 您需要使用该名称为Raspberry Pi提供一个本机库,并设置系统属性java.library.path ,使其指向包含本机库的目录。 That means you have to start your Java program with the -D option, for example: 这意味着您必须使用-D选项启动Java程序,例如:

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

where /some/dir is the directory that contains the native library. /some/dir是包含本机库的目录。

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. 您必须找出是否有一个本机库适合您要使用的RXTX库的Raspberry Pi。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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