How does the JNI DLL look for a native DLL dependent on it?

Let's say mine JNI.dll. It depends on native.dll. Now my Java application is calling System.loadLibrary("JNI").

Does the following folder work?

MainFolder
    |--main.exe
    |--SubFolder
          |--JNI.dll
          |--native.dll

I assume that there are 2 levels of dependency resolution.

[Level 1]:

System.loadLibrary("JNI")uses the JVM property java.library.pathto search JNI.dll.

[Level 2]:

JNI.dllrelies on the Windows system engine to find native.dll.

It is right?

If I set %_JAVA_OPTIONS%how -Djava.library.path=MainFolder\SubFolder, I think it can cover the search JNI.dll. But will it cover the search native.dlltoo?

ADD 1

, 2 : "java.library.path" Eclipse ( )

kevin cline. LD_LIBRARY_PATH Linux.

ADD 2

, . .

: JNI.dll native.dll. main.exe. CWD.

main.exe , java.library.path = <other path>\MainFolder\SubFolder. .

Eclipse, , java.library.path, "\ MainFolder\SubFolder" % PATH%.

, Eclipse .

+4
2

: DLL bin JDK?

: PATH ... winmerge , PATH

, , % Path% . , DLL, end % PATH% . !

, , DLL Windows, . Windows Bug.

Windows, DLL-, . ! .

User% PATH% . , , .

C:\MinGW\bin User% PATH%, , , libstdc++-6.dll (977KB), , , , (825KB). , MinGW.

. : , DLL, MinGW?

0

1) .

2) , , C:\Windows\System32 ( CSIDL_SYSTEM shgetspecialfolderpath() , )

3) Windows (C:\Windows) (CSIDL_WINDOWS shgetspecialfolderpath(), )

4) , PAth environmnet

+1

Source: https://habr.com/ru/post/1584291/


All Articles