Skip to content

Unable to load library 'X11' with 3.3.0, fine with 3.2.7 #12

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

Closed
tulskiy opened this issue Jul 15, 2011 · 5 comments
Closed

Unable to load library 'X11' with 3.3.0, fine with 3.2.7 #12

tulskiy opened this issue Jul 15, 2011 · 5 comments

Comments

@tulskiy
Copy link
Contributor

tulskiy commented Jul 15, 2011

Here is a simple class that loads an X11 library and maps some function:

public class Test {
    static {
        Native.register("X11");
    }

    public static native Pointer XOpenDisplay(String name);


    public static void main(String[] args) {
        XOpenDisplay(null);
    }
}

it all works fine with jna 3.2.7, but with 3.3.0, I get the following exception:

Exception in thread "main" 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.NativeLibrary.getInstance(NativeLibrary.java:202)
    at com.sun.jna.Native.register(Native.java:1032)
    at com.tulskiy.keymaster.Test.<clinit>(Test.java:12)

it seems to be finding the library fine, but always fails in Native.open(). Interface mapping fail as well. I'm running Ubuntu 10.10 32-bit.

@twall
Copy link
Contributor

twall commented Jul 15, 2011

Are you using a libjnidispatch.so from the ubuntu system? the JNI stubs between 3.2.7 and 3.3.0 are not compatible.

On Jul 15, 2011, at 10:05 AM, tulskiy wrote:

Here is a simple class that loads an X11 library and maps some function:

public class Test {
   static {
       Native.register("X11");
   }

   public static native Pointer XOpenDisplay(String name);


   public static void main(String[] args) {
       XOpenDisplay(null);
   }
}

it all works fine with jna 3.2.7, but with 3.3.0, I get the following exception:

Exception in thread "main" 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.NativeLibrary.getInstance(NativeLibrary.java:202)
  at com.sun.jna.Native.register(Native.java:1032)
  at com.tulskiy.keymaster.Test.<clinit>(Test.java:12)

it seems to be finding the library fine, but always fails in Native.open(). Interface mapping fail as well. I'm running Ubuntu 10.10 32-bit.

Reply to this email directly or view it on GitHub:
#12

@twall
Copy link
Contributor

twall commented Jul 15, 2011

FYI, notice that the UnsatisfiedLinkError is caused by being unable to find the native method "com.sun.jna.Native.open(Ljava/lang/String;)J".

The VM attempting to bind the Native.open method is indistinguishable from the JNI layer throwing the same exception in response to being unable to open the requested library (except for the exception message itself).

On Jul 15, 2011, at 10:05 AM, tulskiy wrote:

it all works fine with jna 3.2.7, but with 3.3.0, I get the following exception:

```java
Exception in thread "main" 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.NativeLibrary.getInstance(NativeLibrary.java:202)
  at com.sun.jna.Native.register(Native.java:1032)
  at com.tulskiy.keymaster.Test.<clinit>(Test.java:12)

@tulskiy
Copy link
Contributor Author

tulskiy commented Jul 15, 2011

Umm, I'm not using ubuntu packages. It is a maven project with java.net m2 repo.

@whatnick
Copy link

What do your JVM launch options look like ? I typically have both jna.library.path and java.library.path set.

@tulskiy
Copy link
Contributor Author

tulskiy commented Jul 16, 2011

OK, I've set java.library.path to /usr/lib with 3.3.0 and it works now, thank you. But I'm not setting neither jna.library.path nor java.library.path with 3.2.7 library and all works fine on Ubuntu 10.10, 11.04, Arch and Gentoo.

I guess the issue is closed, thank you.

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

3 participants