Java.lang.UnsatisfiedLinkError: native library {____. dll} already loaded into another classloader

I use my own JAR file, which uses the Java library (JHDF5), which in turn uses the DLL through the JNI. When I use my own JAR file in MATLAB and then have to rebuild it during debugging, I get this error when I try to use it again after calling clear javaand creating a new object from my JAR file:

java.lang.UnsatisfiedLinkError: 
Native Library C:\deka\proj\java\ESPDF\dist\lib\jhdf5.dll 
already loaded in another classloader

and I cannot solve it without closing MATLAB and rediscovering what is a pain in the neck.

What is this error and whose error is it? (mine? MATLAB? JHDF5 so as not to free the DLL or to check if it is loaded)

+3
source share
1 answer

In general, there is no way for Java code to offload the native dll. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5075039

Given that as soon as the DLL loads, it is there for the life of the JVM and VM to ensure that it will be loaded once and only once.

To answer the fault question, I believe this is a code error that tries to load the DLL without checking if it is already available.

+5
source

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


All Articles