I would like to use an existing static C++ library in my Java program. I read that it should be possible. And the steps would be (nearly) the same as for linking dynamic libraries. Unfortunately if I try to load the library with:
static {
System.loadLibrary("mylibrary");
}
I get an exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no mylibrary in java.library.path
I tried setting the java.library.path before the System.loadLibrary
call manually, but it does not help:
System.setProperty("java.library.path", "/workspace/LibraryTest/lib/");
Setting LD_LIBRARY_PATH
in run configurations for the project does also not fix the problem. I get the same error. For shared libraries it works fine though. Currently I'm using Oracle Java8 in Eclipse Mars on Debian Jessie. Does the library need to hava a JNI_OnLoad_mylibrary
method? Anyone experienced similar problems?
EDIT
tried /usr/lib directory and added JNI_OnLoad_mylibrary
. No success.