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

妖精的绣舞 提交于 2019-11-27 18:13:01

问题


Fedora using right now (package is installed Package rxtx-2.2-0.5.20100211.fc15.i686 already installed and latest version ).

I have used/tried:

# locate librxtxSerial
/home/sun/Downloads/rxtx-2.1-7-bins-r2/Linux/i686-unknown-linux-gnu/librxtxSerial.so
/home/sun/Downloads/rxtx-2.1-7-bins-r2/Linux/ia64-unkown-linux-gnu/librxtxSerial.so
/home/sun/Downloads/rxtx-2.1-7-bins-r2/Linux/x86_64-unknown-linux-gnu/librxtxSerial.so
/home/sun/Downloads/rxtx-2.1-7-bins-r2/Mac_OS_X/librxtxSerial.jnilib
/home/sun/Downloads/rxtx-2.1-7-bins-r2/Solaris/sparc-solaris/sparc32-sun-solaris2.8/librxtxSerial-2.1-7.so
/home/sun/Downloads/rxtx-2.1-7-bins-r2/Solaris/sparc-solaris/sparc32-sun-solaris2.8/librxtxSerial.so
/home/sun/Downloads/rxtx-2.1-7-bins-r2/Solaris/sparc-solaris/sparc64-sun-solaris2.8/librxtxSerial-2.1-7.so
/home/sun/Downloads/rxtx-2.1-7-bins-r2/Solaris/sparc-solaris/sparc64-sun-solaris2.8/librxtxSerial.so
/usr/lib/rxtx/librxtxSerial-2.2pre1.so
/usr/lib/rxtx/librxtxSerial.so

Then used:

-Djava.library.path=/usr/lib/rxtx/librxtxSerial.so -Djava.library.path=/usr/lib/jni

But still i get always this following:

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
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
    at java.lang.Runtime.loadLibrary0(Runtime.java:840)
    at java.lang.System.loadLibrary(System.java:1047)
    at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:83)
    at main.Tty.sendCommand1(Tty.java:212)
    at main.Tty.main(Tty.java:236)

How to resolve this ?

Follow up:

WRONG:

-Djava.library.path=/usr/lib/rxtx -Djava.library.path=/usr/lib/jni

CORRECT

-Djava.library.path=/usr/lib/jni -Djava.library.path=/usr/lib/rxtx


回答1:


I guess the problem is that you have multiple -Djava.library.path parameters and the second one is overwriting the value of the first. The value should also be the path to the folder containing the library, not including the library name.

On linux system you should be able to combine both path parameters using a colon as separator:

-Djava.library.path=/usr/lib/rxtx:/usr/lib/jni



回答2:


Had same problem with v4l4j library installed from repositories. In ununtu netbeans project failed to start from IDE, but worked fine as jar.

Solved by putting *.so files to /usr/lib not /usr/lib/jni folder.




回答3:


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 (.DLL, .so, .dylib).




回答4:


We had the same problem on linux. The key for us to fix it was

  1. Use colon ":" to separate java.library.path elements
  2. Use forward slash for directory separators

In our case we used a relative path like this

-Djava.library.path=jar/linux64:jars

The path is relative to the startup path. E.g. when running from netbeans the startup directory is the project directory.




回答5:


Copy RXTXcomm.jar ---> <JAVA_HOME>\jre\lib\ext

Copy rxtxSerial.dll ---> <JAVA_HOME>\jre\bin

Copy rxtxParallel.dll ---> <JAVA_HOME>\jre\bin



来源:https://stackoverflow.com/questions/10751304/java-lang-unsatisfiedlinkerror-no-rxtxserial-in-java-library-path-thrown-while

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!