How to debug java system.loadlibrary error in Linux?

I have a Java program that calls C code via JNI, which I am trying to run on Linux. The external code consists of two .so files: one for JNI bindings (built-in with swig), and the other with actual functions. I have two libraries in the same directory, and LD_LIBRARY_PATH is set correctly. ldd does not report problems when starting from the command line, but when I set LD_LIBRARY_PATH to the same value in the "Startup Configuration" dialog box in the Eclipse editor and try to execute the program, it gets the following error:

java.lang.UnsatisfiedLinkError: [path to libraries] / [JNI binding library] .so: [actual code library] .so: cannot open shared objects file: there is no such file or directory

This makes me think that the JNI wrapper library was loaded successfully, but there is an error when this library tries to load the library containing the actual code. Is there any way to debug this further?

I also want to note that this problem occurs in the eclipse editor itself and that I am not trying to pack the code in a jar and run it in a standalone jvm instance.

+4
source share
7 answers

I think the problem is with calling System.loadLibrary (String) and using LD_LIBRARY_PATH. Using loadLibrary ("foo") will look in your java.library.path for something called libfoo.so. If nothing is found by the name libfoo.so, you will get this error.

, LD_LIBRARY_PATH, , -Djava.library.path.

swig gdal , LD_LIBRARY_PATH , .

-Djava.library.path loadLibrary , - webstart, loadLibrary, .

eclipse, , , "" . , java.library.path .

+2

-Djava.library.path=actual.so , ?

Windows , DLL- JNI DLL. DLL lib, lib PATH (, PATH=%PATH%;./lib, .

0

, Eclipse LD_LIBRARY_PATH. - → Java → JRE, ( ) Jar File, , "Native Library Location", "Edit..." , . , -Djava.library.path, , .

0

, , -Djava.library.path =.... Offhand , -D " vm" arguments, LD_LIBRARY_PATH, . Eclipse , , , . , , , , , .

, - LD_DEBUG. LD_DEBUG ( ALL), linux , , .. , , eclipse , env vars ; , , , - -, eclipse, .

0

, ? , , JVM.

, "-Djava.library.path" .

, :

public class LibTest {
    public static void main(String[] args) {
        String property = System.getProperty("java.library.path");
        StringTokenizer parser = new StringTokenizer(property, ":");
        while (parser.hasMoreTokens()) {
            System.err.println(parser.nextToken());
        }
    }
}

eclipse Java 1.6.0_14:

/opt/java/jre/lib/i386/client
/opt/java/jre/lib/i386
/opt/java/jre/../lib/i386
/opt/java/jre/lib/i386/client
/opt/java/jre/lib/i386
/usr/lib/xulrunner-devel-1.9.0.11
/usr/lib/xulrunner-devel-1.9.0.11
/usr/java/packages/lib/i386
/lib
/usr/lib

JVM arg "-Djava.library.path =/tmp/", :

/tmp/

java.library.path, , ldd , .so eclipse/java.

java.library.path System.load System.loadLibrary. JVM .so - .

, , jni- "-verbose: jni" . .

0
source

Yes LD_LIBRARY_PATH worked for me

0
source

Adding this answer may be helpful. On AIX machines, we need to configure the LIBPATH environment variable instead of LD_LIBRARY_PATH.

0
source

All Articles