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

Swing crashes when having bad native link #19

Closed
patrickballeux opened this issue Aug 15, 2014 · 4 comments
Closed

Swing crashes when having bad native link #19

patrickballeux opened this issue Aug 15, 2014 · 4 comments

Comments

@patrickballeux
Copy link

Hi,

I am using jKeyMaster in my project ScreenStudio (screenstudio.crombz.com). The library does work well. But I am facing one issue where I'm trying to catch the exception is some libraries are missing.

Basically, I have this case:

  • jna.jar is available
  • Ubuntu 14.04 libjna-java is installed

Using a "third-party" jna.jar instead of the native one, there is an issue between jna.jar and the libjna-java libraries. This is a case that can happen when people are not installer the proper dependencies.

What I am trying to do is to catch the error to be able to tell the user that the current setup is not working as expected and "Hot keys" won't work.

This is the exception from the console...
15-Aug-2014 10:30:46 AM com.tulskiy.keymaster.x11.X11Provider$1 run
INFO: Starting X11 global hotkey provider
Exception in thread "Thread-1" java.lang.UnsatisfiedLinkError: Can't obtain updateLastError method for class com.sun.jna.Native
at com.sun.jna.Native.initIDs(Native Method)
at com.sun.jna.Native.(Native.java:139)
at com.tulskiy.keymaster.x11.X11.(X11.java:31)
at com.tulskiy.keymaster.x11.X11Provider$1.run(X11Provider.java:54)
at java.lang.Thread.run(Thread.java:701)

The problem is that I cannot catch the exception, coming from a thread and basically, the Swing GUI does not show making impossible showing an error message to the user.

I am using jKeymaster 1.1 binary build.

Possible solutions: Have an event "OnError" or throw an exception on the ".reset" or the ".register".

I will try to find a work-around but it would be nice if the exception would not freeze the main program.

Thanks!

@tulskiy
Copy link
Owner

tulskiy commented Aug 15, 2014

yes, there seems to be a conflict between your system jna, and what the library is using. See java-native-access/jna#281

possible workaround is to pass "-Djna.nosys=true" to the java process.
also, to catch this error, make sure to have catch (Throwable e) instead of catch (Exception e)

I'll try to update jna dependency to latest version, so that there is no conflict. If nothing seems to break, I'll release a new version ;)

@patrickballeux
Copy link
Author

Thanks for the quick answer.

I will try that. I did found a workaround by initializing the Producer in
its own thread freeing the main thread from the generated exceptions.

Would you mind if I did a screencast about your project? With
ScreenStudio, I am also producing youtube videos about development and cool
user friendly apps on Ubuntu. I'm always on the lookout for new ideas.

You library is so easy to use and implements. I think it's worth doing a
screencast about it in my live coding sessions.

Have a great day!

Patrick Balleux

http://about.me/patrickballeux

Le 2014-08-15 à 14:23, Denis Tulskiy [email protected] a écrit :

yes, there seems to be a conflict between your system jna, and what the
library is using. See java-native-access/jna#281
java-native-access/jna#281

possible workaround is to pass "-Djna.nosys=true" to the java process.
also, to catch this error, make sure to have catch (Throwable e)
instead of catch
(Exception e)

I'll try to update jna dependency to latest version, so that there is no
conflict. If nothing seems to break, I'll release a new version ;)


Reply to this email directly or view it on GitHub
#19 (comment).

@tulskiy
Copy link
Owner

tulskiy commented Aug 16, 2014

yeah, feel free to do a screencast :)

@tulskiy
Copy link
Owner

tulskiy commented Aug 16, 2014

could you please also try snapshot version with latest jna version? https://github.com/tulskiy/jkeymaster/blob/master/README.md#maven

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

2 participants