On Oct 17, 2007, at 5:45 PM, Rui Caridade wrote:
// The test
NativeLibrary.addSearchPath("libjIso.so","/home/persefone/Esoteric/
jar/native/linux/");
iso9660Lib iso =
(iso9660Lib)NativeLibrary.getInstance("libjIso.so");
You technically only need "jIso" as the library name, although on
linux the full filename probably works as well.
You will, however, get a class cast exception when NativeLibrary
finally returns a value. You need to use Native.loadLibrary(), which
returns an instance of your interface bound to the native library,
not NativeLibrary.getInstance(), which returns a NativeLibrary object.
Exception in thread "main"
java.lang.UnsatisfiedLinkError: Unable to load library
'libjIso.so'
at
com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:100)
at
com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:139)
at test.main(test.java:14)
I'm running this from within eclipse.The jar is on the
classpath but not on the same dir as the libs i'm
calling can that be the reason.This is the first time
i'm trying to use jna so please feel free to point my
stupid mistakes..
JNA uses the path specified in jna.library.path to search for
libraries, and falls back to the system path if that fails (in this
case, LD_LIBRARY_PATH). Neither java.class.path nor
java.library.path is used to look up user libraries.
Setting jna.library.path is usually preferable to hard-coding paths.
Since you're using eclipse, why don't you just put a breakpoint on
the offending exception and examine the paths being tried? It might
be something as simple as a typo in your path string.