kwhat / jnativehook

Global keyboard and mouse listeners for Java.
Other
1.75k stars 347 forks source link

"Failed to launch JVM" error due to lack of write permissions when installing to C:\Program Files #469

Open s97712 opened 2 months ago

s97712 commented 2 months ago

I used a packaging tool to install the application into C:\Program Files. However, the library tries to release a DLL file into the program directory during runtime. Since there are no write permissions, the DLL fails to be released, and the program throws a "Failed to launch JVM" error. Is there a way to install to C:\Program Files and allow the program to run properly?

s97712 commented 2 months ago

Is there a way to package the DLL along with the program during the build process, instead of releasing it at runtime? I'm using Gradle to package my application, but I know nothing about Gradle. It's really complicated and hard to understand. I've tried to figure it out, but I'm getting nowhere.

kwhat commented 2 months ago

See: https://github.com/kwhat/jnativehook/issues/467#issuecomment-2286812868

s97712 commented 2 months ago

Maybe extracting to the AppData directory or another directory instead of the app's installation directory could solve a lot of troubles.

kwhat commented 2 months ago

It should be as easy as extracting the target shared library and shipping it along side of the app. You just need to set the java.library.path to the location of the extracted / installed library and name the file appropriately.