I'm working on studens project, which will need to read data send from AtMega via USB (using virtual serial port). To access serial port I'm using NeuronRobotics' nrjavaserial (https://github.com/NeuronRobotics/nrjavaserial), which is a fork of RXTX. To manage my dependencies I'm using maven. Here's what I get when I run CommPortIdentifier.getPortIdentifiers();
(or whichever static CommPortIdentifier
function):
java.lang.UnsatisfiedLinkError: C:\Users\Grześ\AppData\Local\Temp\libNRJavaSerial_Grze?_0\libNRJavaSerial.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1821)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at gnu.io.NativeResource.loadResource(NativeResource.java:142)
at gnu.io.NativeResource.inJarLoad(NativeResource.java:40)
at gnu.io.NativeResource.loadLib(NativeResource.java:60)
at gnu.io.NativeResource.load(NativeResource.java:28)
at gnu.io.SerialManager.<init>(SerialManager.java:10)
at gnu.io.SerialManager.getInstance(SerialManager.java:16)
at gnu.io.RXTXCommDriver.<clinit>(RXTXCommDriver.java:87)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:109)
at pl.edu.pwr.aerospace.enginebench.serial.SerialCommunicator.getAvaliablePorts(SerialCommunicator.java:34)
at pl.edu.pwr.aerospace.enginebench.cli.Main.connectCommunicator(Main.java:35)
at pl.edu.pwr.aerospace.enginebench.cli.Main.main(Main.java:21)
java.lang.UnsatisfiedLinkError: C:\Users\Grześ\AppData\Local\Temp\libNRJavaSerial_Grze?_0\libNRJavaSerial.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1821)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at gnu.io.NativeResource.loadResource(NativeResource.java:142)
at gnu.io.NativeResource.inJarLoad(NativeResource.java:40)
at gnu.io.NativeResource.loadLib(NativeResource.java:60)
at gnu.io.NativeResource.load(NativeResource.java:28)
at gnu.io.SerialManager.<init>(SerialManager.java:10)
at gnu.io.SerialManager.getInstance(SerialManager.java:16)
at gnu.io.RXTXCommDriver.<clinit>(RXTXCommDriver.java:87)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:109)
at pl.edu.pwr.aerospace.enginebench.serial.SerialCommunicator.getAvaliablePorts(SerialCommunicator.java:34)
at pl.edu.pwr.aerospace.enginebench.cli.Main.connectCommunicator(Main.java:35)
at pl.edu.pwr.aerospace.enginebench.cli.Main.main(Main.java:21)
java.lang.ExceptionInInitializerError thrown while loading gnu.io.RXTXCommDriver
java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXCommDriver thrown while loading gnu.io.RXTXCommDriver
Here are my dependencies:
<dependencies>
<dependency>
<groupId>com.neuronrobotics</groupId>
<artifactId>nrjavaserial</artifactId>
<version>3.12.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
Strangly, this only happens during debugging, when I run program normally it works like charm. Any ideas why?
I found that people had similar problems with other libraries, however solutions for all of them was to move DLLs or update classpath, but as I'm using maven I suspect in this case the solution will be different.
I managed to fix my problem. The root cause of this problem, was my username - "Grześ", which contains non-standard character 'ś'. As you may see in the first line of exception info:
java.lang.UnsatisfiedLinkError: C:\Users\Grześ\AppData\Local\Temp\libNRJavaSerial_Grze?_0\libNRJavaSerial.dll: Can't find dependent libraries
The path contains question mark in place of this character. Changing my username in Windows properties fixed this issue