Arne Arne - 5 months ago 22
Java Question

System.LoadLibrary() doesn't find Library

I have a library

/home/me/myfolder/mylib.so


and when executing

System.out.println(System.getProperty("java.library.path"));


I get the
/home/me/myfolder
. But if I try to load it:

System.loadLibrary("mylib");


This error happens:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no mylib.so in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at MainClass.main(MainClass.java:11)


Already tried to use
mylib.so
instead. The library was created from Haskell Code.

Answer

On Linux/Unix, I believe it will look for lib<name>.so, so try renaming your library to /home/me/myfolder/libmylib.so, and loading it with System.loadLibrary("mylib");.

Comments