tulskiy / jkeymaster

A library for registering global hotkeys in java with JNA. The goal is to support X11-based platforms, Windows and MacOSX
GNU Lesser General Public License v3.0
234 stars 45 forks source link

X11Provider.java fails on Ubuntu 11.10 #3

Closed scmurdock closed 12 years ago

scmurdock commented 12 years ago

Hello- I've been working with your package and am very happy to find it. I previously worked with another package that relies heavily on JNI. Running your example code ProviderTest.java produces the following stack trace:

Nov 10, 2011 6:48:03 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Starting X11 global hotkey provider Exception in thread "Thread-1" java.lang.UnsatisfiedLinkError: Unable to load library 'X11': com.sun.jna.Native.open(Ljava/lang/String;)J at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:166) at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:239) at com.sun.jna.Library$Handler.(Library.java:140) at com.sun.jna.Native.loadLibrary(Native.java:393) at com.sun.jna.Native.loadLibrary(Native.java:378) at com.tulskiy.keymaster.x11.X11.(X11.java:29) at com.tulskiy.keymaster.x11.X11Provider$1.run(X11Provider.java:56) at java.lang.Thread.run(Thread.java:679)

I noticed you posted a similar error on the JNA project site. I don't seem to be able to fix it using your fix mentioned:

https://github.com/twall/jna/issues/12

Perhaps I'm not putting the line of code in the right place or perhaps I don't have a symlink where it ought to be, but here's the code I added:

X11Provider.java

public void init() {
    Runnable runnable = new Runnable() {
        public void run() {
            logger.info("Starting X11 global hotkey provider");
            System.setProperty("java.library.path", "/usr/lib/");//added per https://github.com/twall/jna/issues/12 [sean] 11-10-11
            display = Lib.XOpenDisplay(null);

It still fails. I'm not too familiar with JNA, but would really love to get this to work on Ubuntu 11.10 :)

Any help is greatly appreciated.

Thanks!

Sean

scmurdock commented 12 years ago

FYI I've also tested the following, to no avail:

             System.setProperty("java.library.path", "/usr/lib/i386-linux-gnu");
tulskiy commented 12 years ago

Hi, Sean,

I don't think modifying these variables from code will work, try adding these params to the java vm as:

java -Djava.library.path=/usr/lib -cp example.jar YourClass

Also, are you on a 64-bit OS? I'm using this library on a Ubuntu 11.10 32-bit and all works fine.

scmurdock commented 12 years ago

I'm on a 32 bit OS. I tried the following command. The jar file has a main method specified when building from eclipse and it even tries to run (hence the original error). Yet after using the options specified I invariably get this:

$ java -D java.library.path=/usr/lib -cp JavaKeyTest.jar Exception in thread "main" java.lang.NoClassDefFoundError: java/library/path=/usr/lib Caused by: java.lang.ClassNotFoundException: java.library.path=.usr.lib at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) Could not find the main class: java.library.path=/usr/lib. Program will exit.

On Thu, Nov 10, 2011 at 10:30 AM, Denis Tulskiy < reply@reply.github.com>wrote:

Hi, Sean,

I don't think modifying these variables from code will work, try adding these params to the java vm as:

java -Djava.library.path=/usr/lib -cp example.jar YourClass

Also, are you on a 64-bit OS? I'm using this library on a Ubuntu 11.10 32-bit and all works fine.


Reply to this email directly or view it on GitHub: https://github.com/tulskiy/jkeymaster/issues/3#issuecomment-2698279

tulskiy commented 12 years ago

There should be no space after -D, and you need to use -jar instead of -cp if you're running just a jar.

java -Djava.library.path=/usr/lib -jar JavaKeyTest.jar

On Fri, Nov 11, 2011 at 1:45 PM, scmurdock < reply@reply.github.com>wrote:

I'm on a 32 bit OS. I tried the following command. The jar file has a main method specified when building from eclipse and it even tries to run (hence the original error). Yet after using the options specified I invariably get this:

$ java -D java.library.path=/usr/lib -cp JavaKeyTest.jar Exception in thread "main" java.lang.NoClassDefFoundError: java/library/path=/usr/lib Caused by: java.lang.ClassNotFoundException: java.library.path=.usr.lib at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) Could not find the main class: java.library.path=/usr/lib. Program will exit.

On Thu, Nov 10, 2011 at 10:30 AM, Denis Tulskiy < reply@reply.github.com>wrote:

Hi, Sean,

I don't think modifying these variables from code will work, try adding these params to the java vm as:

java -Djava.library.path=/usr/lib -cp example.jar YourClass

Also, are you on a 64-bit OS? I'm using this library on a Ubuntu 11.10 32-bit and all works fine.


Reply to this email directly or view it on GitHub: https://github.com/tulskiy/jkeymaster/issues/3#issuecomment-2698279


Reply to this email directly or view it on GitHub: https://github.com/tulskiy/jkeymaster/issues/3#issuecomment-2705753


Best, Denis Tulskiy

scmurdock commented 12 years ago

Thanks Denis. That worked:

java -Djava.library.path=/usr/lib -jar JavaKeyTest.jar

Nov 11, 2011 7:51:12 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Starting X11 global hotkey provider Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{ctrl alt D} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl 0} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl PLUS} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl INSERT} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl ESCAPE} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl BACK_QUOTE} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl SLASH} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl BACK_SLASH} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl DIVIDE} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl MULTIPLY} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl ENTER} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl MINUS} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl BACK_QUOTE} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl RIGHT} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl INSERT} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl DELETE} Nov 11, 2011 7:51:13 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl ADD} Nov 11, 2011 7:51:14 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl SUBTRACT} Nov 11, 2011 7:51:14 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl COMMA} Nov 11, 2011 7:51:14 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl PERIOD} Nov 11, 2011 7:51:14 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{shift ctrl SEMICOLON} Nov 11, 2011 7:51:14 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{ctrl alt HOME} Nov 11, 2011 7:51:14 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{ctrl alt PAGE_UP} Nov 11, 2011 7:51:14 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Registering hotkey: HotKey{ctrl alt NUMPAD0} Nov 11, 2011 7:52:02 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Received event for hotkey: HotKey{ctrl alt D} HotKey{ctrl alt D} Nov 11, 2011 7:52:02 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Reset hotkeys Nov 11, 2011 7:52:03 AM com.tulskiy.keymaster.x11.X11Provider$1 run INFO: Thread - stop listening

On Fri, Nov 11, 2011 at 1:15 AM, Denis Tulskiy < reply@reply.github.com>wrote:

There should be no space after -D, and you need to use -jar instead of -cp if you're running just a jar.

java -Djava.library.path=/usr/lib -jar JavaKeyTest.jar

On Fri, Nov 11, 2011 at 1:45 PM, scmurdock < reply@reply.github.com>wrote:

I'm on a 32 bit OS. I tried the following command. The jar file has a main method specified when building from eclipse and it even tries to run (hence the original error). Yet after using the options specified I invariably get this:

$ java -D java.library.path=/usr/lib -cp JavaKeyTest.jar Exception in thread "main" java.lang.NoClassDefFoundError: java/library/path=/usr/lib Caused by: java.lang.ClassNotFoundException: java.library.path=.usr.lib at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) Could not find the main class: java.library.path=/usr/lib. Program will exit.

On Thu, Nov 10, 2011 at 10:30 AM, Denis Tulskiy < reply@reply.github.com>wrote:

Hi, Sean,

I don't think modifying these variables from code will work, try adding these params to the java vm as:

java -Djava.library.path=/usr/lib -cp example.jar YourClass

Also, are you on a 64-bit OS? I'm using this library on a Ubuntu 11.10 32-bit and all works fine.


Reply to this email directly or view it on GitHub: https://github.com/tulskiy/jkeymaster/issues/3#issuecomment-2698279


Reply to this email directly or view it on GitHub: https://github.com/tulskiy/jkeymaster/issues/3#issuecomment-2705753


Best, Denis Tulskiy


Reply to this email directly or view it on GitHub: https://github.com/tulskiy/jkeymaster/issues/3#issuecomment-2705910