1

I load C++ JNI DLL on my Java project. It works quietly good on JDK 1.6 but there is a probelm JDK 1.8. Is there any change in C++ JNI DLL loading in Java 1.8?

I have attached errors and result below.

JDK 1.8 Console :

Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\ws-pidion\PidionSDK\oojnidotnet.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at JavaCallNative.<clinit>(JavaCallNative.java:14)

Codes:

File readReturnNativeStringVaueFile;

static {
    System.loadLibrary("oojnidotnet");
}

protected void finalize() throws Throwable {
    super.finalize();
}

public native boolean connect(String paramString);

Same codes work with JDK 1.6.

Thanks.

  • The error message suggests that your DLL depends on other DLLs, of which one could not be found. Do you know, which dependencies your DLL has? See also [“How to check for DLL dependency?”](http://stackoverflow.com/q/7378959/2711488) – Holger Dec 07 '16 at 09:31
  • Yes, I know dependencies other DLL. And same directory with my project. My project work in JDK 1.6. What is different between JDK 1.6 and JDK 1.8? Security for path? – umut.bayram Dec 07 '16 at 10:57
  • So the DLL is not using JNI nor system DLLs? It’s hard to believe that *all* required libraries are in the same directory. So it’s still possible that there is an absolute path or a reference to a library that doesn’t exist unter Java 8. You should *check* instead of believing. – Holger Dec 07 '16 at 11:02
  • I recommend you to use System.load("Path of dll") instead of System.loadLibrary() – Tarik FAMIL Dec 07 '16 at 11:45
  • or set LD_LIBRARY_PATH to point to the directory where the compiled library is stored – Tarik FAMIL Dec 07 '16 at 11:52
  • JDK 1.6 (32 bit) came with msvcr71.dll that JDK 1.8 doesn't use anymore. Maybe that's the "dependent library" that you're missing. (See the answer at Holger's link to see how to check this) – user2543253 Dec 08 '16 at 16:38
  • Tarık, I try 'System.load("Path of dll")', same. User, I dont find msvcr71.dll. Why is need it ? Why doesnt include JDK 1.8 ? Where do i find one ? – umut.bayram Dec 12 '16 at 09:04
  • 1
    msvcrt71.dll is the C runtime library for Visual Studio 2003. If your DLL was built with that IDE, chances are that you need the runtime library. Again: you should check your DLL with the tool referenced by Holger's link to see if it is indeed the one that you're missing. If yes, search the *net for "Visual C++ 2003 redistributable". It was part of the .NET download at some time, but I don't know where it is now. As to why JDK 1.8 doesn't have it: they replaced their ancient C compiler with a newer version that requires a newer runtime library. – user2543253 Dec 12 '16 at 11:23
  • Thanks user, Other need npjp2.dll and work now. – umut.bayram Dec 12 '16 at 12:21

1 Answers1

1

I solved this problem with user2543253s helping.

For JDK 1.8:

  • Need 2 DLL Lib (C:\Program Files (x86)\Java\jdk1.6.0_45\jre\bin\plugin2) (2 DLL libs copy to project path. )

    System.loadLibrary("msvcr71");
    System.loadLibrary("npjp2");
    
    System.loadLibrary("oojnidotnet");
    

It works this way in 1.8.

Thanks.