java - JNA library and native library not found error -


i want use jna detect foreground application on linux (ubuntu 14). followed link find out application (window) in focus in java got following error:

exception in thread "main" java.lang.unsatisfiedlinkerror: unable load library 'xlib': native library (linux-x86-64/libxlib.so) not found in resource path ([file:/home/zzhou/workspace/home_prioritization_plus/bin/, file:/home/zzhou/downloads/jna-4.1.0.jar, file:/home/zzhou/downloads/jna-platform-4.1.0.jar])     @ com.sun.jna.nativelibrary.loadlibrary(nativelibrary.java:271)     @ com.sun.jna.nativelibrary.getinstance(nativelibrary.java:398)     @ com.sun.jna.library$handler.<init>(library.java:147)     @ com.sun.jna.native.loadlibrary(native.java:412)     @ com.sun.jna.native.loadlibrary(native.java:391)     @ functionalitytest$xlib.<clinit>(functionalitytest.java:15)     @ functionalitytest.main(functionalitytest.java:23) 

the code is:

import com.sun.jna.native; import com.sun.jna.platform; import com.sun.jna.pointer; import com.sun.jna.platform.unix.x11; import com.sun.jna.win32.stdcalllibrary;  public class functionalitytest {      static class psapi {         static { native.register("psapi"); }         public static native int getmodulebasenamew(pointer hprocess, pointer hmodule, char[] lpbasename, int size);     }      public interface xlib extends stdcalllibrary {         xlib instance = (xlib) native.loadlibrary("xlib", psapi.class); // <-- problem          int xgetinputfocus(x11.display display, x11.window focus_return, pointer revert_to_return);     }      public static void main(string args[]) {         if(platform.islinux()) {  // possibly of unix systems work here too, e.g. freebsd             final x11 x11 = x11.instance;             final xlib xlib= xlib.instance;             x11.display display = x11.xopendisplay(null);             x11.window window=new x11.window();             xlib.xgetinputfocus(display, window,pointer.null);             x11.xtextproperty name=new x11.xtextproperty();             x11.xgetwmname(display, window, name);             system.out.println(name.tostring());         }     }  } 

to import jna library, downloaded jna , jna-platform https://github.com/twall/jna , use configure build path... in eclipse add library. did not install anything. may source of problem?

thanks help.

afaik, jna, have load library in java in order jna find it. (tested win32, not linux)

try above native.loadlibrary:

system.loadlibrary("xlib"); 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -