Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.35k stars 287 forks source link

UnsatisfiedLinkError - Cannot Access Process #101

Closed DuluthIsSuperior closed 6 years ago

DuluthIsSuperior commented 6 years ago

I'm trying to compile a program in Java with the jSerialComm package. It compiles just fine, but whenever I try to run it, it always throws these exceptions whenever .getCommPorts() is called:

java.lang.NullPointerException at com.fazecast.jSerialComm.SerialPort.<clinit>(SerialPort.java:172) at Main.openPort(Main.java:126) at Main.main(Main.java:148) Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\Kyle\AppData\Local\Temp\1516669852283-jSerialComm.dll: The process cannot access the file because it is being used by another process at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(Unknown Source) at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.load0(Unknown Source) at java.lang.System.load(Unknown Source) at com.fazecast.jSerialComm.SerialPort.<clinit>(SerialPort.java:181) at Main.openPort(Main.java:126) at Main.main(Main.java:148)

It just started working out of the blue but I don't know what fixed it (or if it is fixed). It runs fine in Eclipse, but when I run it outside of Eclipse is when this problem occurs. There's nothing open that uses Java, according to Task Manager, and Eclipse is closed out before I attempt to run this. Any help would be greatly appreciated.

anilsamuel commented 6 years ago

The DLL is extracted to temp folder and then loaded by the java runtime. The issue seen here is caused by windows still having open file handle to this file; probably delete all files in C:\Users\Kyle\AppData\Local\Temp\ and restart the PC and try again.

On Tue, Jan 23, 2018 at 12:42 PM, Pyrodron notifications@github.com wrote:

I'm trying to compile a program in Java with the jSerialComm package. It compiles just fine, but whenever I try to run it, it always throws these exceptions whenever .getCommPorts() is called:

java.lang.NullPointerException at com.fazecast.jSerialComm. SerialPort.(SerialPort.java:172) at Main.openPort(Main.java:126) at Main.main(Main.java:148) Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\Kyle\AppData\Local\Temp\1516669852283-jSerialComm.dll: The process cannot access the file because it is being used by another process at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(Unknown Source) at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.load0(Unknown Source) at java.lang.System.load(Unknown Source) at com.fazecast.jSerialComm.SerialPort.(SerialPort.java:181) at Main.openPort(Main.java:126) at Main.main(Main.java:148)

It just started working out of the blue but I don't know what fixed it (or if it is fixed). It runs fine in Eclipse, but when I run it outside of Eclipse is when this problem occurs. There's nothing open that uses Java, according to Task Manager, and Eclipse is closed out before I attempt to run this. Any help would be greatly appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Fazecast/jSerialComm/issues/101, or mute the thread https://github.com/notifications/unsubscribe-auth/ANieH_AyID6yjIW7s_7Nram1eYl8qixbks5tNTkXgaJpZM4Ro71R .

-- "The part of me that pains the most also gets me out of bed, w/out your hope there would be nothing left…" - Late Kayla Mueller "Play your role in life with such passion, that even after the curtains come down, the applause doesn't stop." - Late Colonel Munindra Nath Rai

DuluthIsSuperior commented 6 years ago

I apologize for the long wait, I got caught up with school work.

I tried deleting everything in the Temp folder both through Disk Cleaner and then going to the folder and deleted everything that wasn't in use manually. Neither have resolved the problem.

hedgecrw commented 6 years ago

The only time this error occurs is if your Java code is somehow trying to initialize the jSerialComm library twice in quick succession. I will make a change to ensure that this doesn't throw an error any more, but you should also check your code to see why this is happening in the first place as it could cause other issues down the road. Perhaps your program is including the jSerialComm library twice?

This error will be fixed in version 2.0.2 (released in an hour or so).