kwhat / jnativehook

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

fail to load .so when project is in a directory containing space #369

Closed symlc112233 closed 3 years ago

symlc112233 commented 3 years ago

Hi, I was running the "Global Keyboard Listener" test on ubuntu 20.04, and the program crashed when run from a directory containing space. I was using "jnativehook-2.2.0.jar" directly, with the command:

java -cp "bin:lib/*" Test

the error output goes as follows:

Oct 12, 2021 11:44:35 PM com.github.kwhat.jnativehook.GlobalScreen SEVERE: Unable to locate JNI library at /home/bubble/Desktop/coding/java/2021-10-12%20keyboard/lib/jnativehook-2.2.0.jar/com/github/kwhat/jnativehook/lib/linux/x86_64/libJNativeHook.so! \ Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to locate JNI library at /home/bubble/Desktop/coding/java/2021-10-12%20keyboard/lib/jnativehook-2.2.0.jar/com/github/kwhat/jnativehook/lib/linux/x86_64/libJNativeHook.so! \ at com.github.kwhat.jnativehook.GlobalScreen.(GlobalScreen.java:91) at Test.main(Test.java:39)

It is obvious that "%20" in the path caused the problem.

kwhat commented 3 years ago

I just need to quote the path, I'll see if I can take care of it today.

kwhat commented 3 years ago

Snapshot should be available with this fix. You can also grab the latest jar here.

Please reopen if the problem persists.