java-Native.loadLibrary适用于OpenJDK错误,不适用于Oracle JDK

时间:2018-07-11 06:18:28

标签: java linux java-native-interface shared-libraries jna

我想使用jna来加载liblibcc.so.so文件位于/ usr / lib64中。它可以在OpenJDK上运行,但不能在具有相同代码和相同环境的Oracle JDK上运行。我尝试设置'LD_LIBRARY_PATH ','jna.library.path','java.library.path','path',但它不起作用。我的问题是两个jdk有什么区别。

以下是不同的结果: Oracle JDK:

Trying (via loadLibrary) jnidispatch
Looking in classpath from sun.misc.Launcher$AppClassLoader@73d16e93 for /com/sun/jna/linux-x86-64/libjnidispatch.so
Found library resource at jar:file:/root/jna_test/jna-4.5.1.jar!/com/sun/jna/linux-x86-64/libjnidispatch.so
Trying /tmp/jna-3506402/jna929667016768875358.tmp
Found jnidispatch at /tmp/jna-3506402/jna929667016768875358.tmp
Looking for library 'msc'
Adding paths from jna.library.path: null
Trying libmsc.so
Adding system paths: [/usr/lib64, /lib64, /usr/lib, /lib, /usr/lib64/atlas, /usr/lib64/dyninst, /usr/lib64/mysql, /usr/lib64/iscsi]
Trying /usr/lib64/libmsc.so
Looking for version variants
Looking in classpath from sun.misc.Launcher$AppClassLoader@73d16e93 for msc
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'msc': Native library (linux-x86-64/libmsc.so) not found in resource path ([file:/root/jna_test/, file:/root/jna_test/jna-4.5.1.jar])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:303)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:427)
    at com.sun.jna.Library$Handler.<init>(Library.java:179)
    at com.sun.jna.Native.loadLibrary(Native.java:569)
    at com.sun.jna.Native.loadLibrary(Native.java:544)
    at tt$CTTS.<clinit>(tt.java:6)
    at tt.main(tt.java:15)

OpenJDK:

Trying (via loadLibrary) jnidispatch
Looking in classpath from sun.misc.Launcher$AppClassLoader@659e0bfd for /com/sun/jna/linux-x86-64/libjnidispatch.so
Found library resource at jar:file:/root/jna_test/jna-4.5.1.jar!/com/sun/jna/linux-x86-64/libjnidispatch.so
Trying /tmp/jna-3506402/jna910656887963138461.tmp
Found jnidispatch at /tmp/jna-3506402/jna910656887963138461.tmp
Looking for library 'msc'
Adding paths from jna.library.path: null
Trying libmsc.so
Found library 'msc' at libmsc.so
ret 0

0 个答案:

没有答案