Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JNativeHook 2.2.2 not working out of the IDE (.jar, .exe, .app) #428

Open
FelipeAumannRS opened this issue Dec 1, 2022 · 11 comments
Open

Comments

@FelipeAumannRS
Copy link

FelipeAumannRS commented Dec 1, 2022

Had to move from 1stleg JNativeHook to kwhat since version 2.2.2 supports mac silicon. 1stleg was working in the productive environment flawlessly, instead of kwhat. For some reason, in my IDE it works just fine with all mouse/keyboard listeners, but when running the application from a jar or any kind of executable it just doesn't work. Here's the stacktrace (exception is thrown at

GlobalScreen.setEventDispatcher(new JavaFxDispatchService());

2022-12-01 20:28:27.972 ERROR 18560 --- [lication Thread] com.github.kwhat.jnativehook : URI is not hierarchical Exception in thread "JavaFX Application Thread" java.lang.UnsatisfiedLinkError: URI is not hierarchical at com.github.kwhat.jnativehook.GlobalScreen.<clinit>(GlobalScreen.java:91) at com.nume.main.core.stage.StageInitializer.onApplicationEvent(StageInitializer.java:119) at com.nume.main.core.stage.StageInitializer.onApplicationEvent(StageInitializer.java:37) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) at com.nume.main.MirroredMain.lambda$start$1(MirroredMain.java:59) at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184) at java.base/java.lang.Thread.run(Thread.java:833)

Interestingly enough, building the jar with maven Shade plugin enables JNativeHook to work properly, although, for deployment reasons, this plugin isn't an option.

Is there anything else I can do in order to use it without Shade plugin?

Tried on MacOS intel, MacOS silicon, Windows 10, java version 17.0.3 correto. Same behavior for all.

@marcin7848
Copy link

I confirm the issue. I've just tested it using gradle, same problem. Versions: 2.2.0 - 2.2.2 doesn't work outside the IDE. I've also tested the earlier version 2.1.0 - works correctly.

@FelipeAumannRS
Copy link
Author

@marcin7848
Thanks for confirming. Unfortunately, a downgrade is not an option since version below 2.2.2 wouldn't work on mac silicon

@thewen99
Copy link

I also encountered this problem. Have you solved it

@FelipeAumannRS
Copy link
Author

@thewen99 it seems like the project is abandoned. So bad, jnativehook is outstanding

@kwhat
Copy link
Owner

kwhat commented Aug 14, 2023

it seems like the project is abandoned. So bad, jnativehook is outstanding

99% of the work happens in libuiohook and there is only one of me.

I doubt this is a bug in the library, but the code in question is located here. There is nothing special about it, see why your IDE doesn't like running it.

You really shouldn't be using the library locator in either production or development. It was provided as a convince because Java's library loading is clunky and confusing. You really should be extracting the the native library you need for your target platform and setting the java.library.path property as Sun intended. This convenience feature causes so many bug reports that it will likely be removed from the next version of this library.

@SpecialCharacter
Copy link

I tried to install JNativeHook 2.2.2.jar via Eclipse but it did not work. Eclipse sees the .jar file but the check box is not checked, and when I go to the dialogue again, the .jar file is gone.

@EtienneLamoureux
Copy link

Same problem here. Anyone found an alternative?

@kwhat
Copy link
Owner

kwhat commented Nov 15, 2023 via email

@FelipeAumannRS
Copy link
Author

@kwhat why though? Why this change is necessary? It sounds like a downgrade, I don't get.

@toni2ve
Copy link

toni2ve commented Jan 9, 2024

I faced the same issue when exporting as a runnable jar from Eclipse. The solution that worked for me was to use the following Library handling option "Copy required libraries into a sub-folder next to the generated JAR" while exporting the runnable jar. This option will put the jnativehook-2.2.2.jar and the JNativeHook-2.2.2.x86_64.dll into a folder next to the runnable jar.
image

@AwesomeYotta
Copy link

AwesomeYotta commented Jan 18, 2024

I extract the JNativeHook.dll file from jnativehook jar file, and put it in the same directory of my application(single jar file), which is also the working directory, and the program could find the dll file perfectly.

I wish this could be done automatically for this cross platform awesome application, huge work for kwhat, definitly, could this feature be extracted and put in a file for the library users to contribute? altogether cover all the details under all circumstances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants