3
votes

I have created a jar file witch uses autohotkey.dll library. Jar runs smoothly on my main pc and laptop, but now I'm trying to use it on pc that has freshly installed windows 10 and I'm getting this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'AutoHotkey': Can't obtain InputStream for win32-x86-64/AutoHotkey.dll at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271) at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398) at com.sun.jna.Library$Handler.(Library.java:147) at com.sun.jna.Native.loadLibrary(Native.java:412) at com.sun.jna.Native.loadLibrary(Native.java:391) at DllController.(DllController.java:26) at UI.main(UI.java:113)

DLL file is located in the same folder as the jar file.

I have tried the following:

  • Using both 32 and 64-bit versions of JRE
  • Installed visual c++ redistributable package (both 32 and 64 bit)
  • Also tried running the jar by the following command:

java "-Djava.library.path=C:\runnablegui\new" -jar C:\runnablegui\new\as.jar

Screenshot from Process Monitor involving the Autohotkey.dll operations: Screenshot from Process Monitor involving the Autohotkey.dll operations

1
Is that a typo here (or in your command)? "-Djava.library.path= C:\runnablegui" should be "-Djava.library.path=C:\runnablegui" - also, double check the folder structure on a working machine (it seems that dll should be in a sub-folder).Elliott Frisch
yes, there was a typo but it did not have any effect. I tried to move the dll to the sub folder on the working pc, but that it also starts to give the same error.Tuukka Peltomäki
Use Sysinternals Process Monitor to check in what path the Java process actually searches for the dll (filter for the Java.exe process and only file operations).Robert
I added the screenshot from the process monitor. If I understood correctly the dll is read from C:\runnableguiTuukka Peltomäki

1 Answers

0
votes

Problem solved. I did not have the newes version ov vc_redist installed