[英]Java can't find libraries in Maven project
I have Java maven project in Eclipse: 我在Eclipse中有Java Maven项目:
I have include required dependencies in pom.xml file and did refresh alt+F5
. 我在pom.xml文件中包含了必需的依赖项,并刷新了
alt+F5
。 I did maven build compile
without errors. 我
did maven build compile
没有错误。 But when I try to run file it looks like java can't load required classes from library: java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver 但是,当我尝试运行文件时,似乎Java无法从库中加载所需的类:java.lang.UnsatisfiedLinkError:加载gnu.io.RXTXCommDriver时,在java.library.path中没有rxtxSerial抛出
Exception in thread "main" java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:83)
at main.TwoWaySerialComm.connect(TwoWaySerialComm.java:20)
at main.TwoWaySerialComm.main(TwoWaySerialComm.java:107)
How to fix that? 如何解决?
You need to run your application with following JVM argument: 您需要使用以下JVM参数运行您的应用程序:
Linux: -Djava.library.path=/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/librxtxSerial.so
Linux:
-Djava.library.path=/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/librxtxSerial.so
Windows: java -Djava.library.path= "your dll path"
Windows:
java -Djava.library.path= "your dll path"
JVM arguments are passed right after java command and before application main class or jar with main class. JVM参数在Java命令之后,应用程序主类或具有主类的jar之前传递。
Copy rxtxSerial.dll
to %JAVA_HOME%/bin .Note:Not the rxtxSerial64.dll
将
rxtxSerial.dll
复制到%JAVA_HOME%/ bin。注意:不是rxtxSerial64.dll
Note:Download the right version , rxtxSerial.dll
has AMD and Intel two different versions. 注意:下载正确的版本,
rxtxSerial.dll
具有AMD和Intel两个不同的版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.