3

I want to use jna to loadlibrary:libmsc.so.The so file is in /usr/lib64.It works on OpenJDK,but not on Oracle JDK with the same code and the same environment.I try to set 'LD_LIBRARY_PATH','jna.library.path','java.library.path','path',but it does not work.My question is what is the difference between the two jdks.

Here are the different results: 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
sgaoym
  • 31
  • 1
  • Is your question really "[What is the difference between the two jdks](https://stackoverflow.com/questions/22358071/differences-between-oracle-jdk-and-openjdk)"? – Kayaman Jul 11 '18 at 06:25
  • The most fundamental problem to be solved is why OpenJDK can but Oracle JDK can not? – sgaoym Jul 11 '18 at 06:46
  • Exactly. The question is not at all "what's the difference between the two jdks". – Kayaman Jul 11 '18 at 06:48

0 Answers0