[英]java.lang.UnsatisfiedLinkError: Native Library {____.dll} already loaded in another classloader
I'm using a JAR file of my own, which uses a Java library (JHDF5), that in turn uses a dll through JNI. 我正在使用我自己的JAR文件,该文件使用Java库(JHDF5),而后者又通过JNI使用dll。 When I use my own JAR file in MATLAB, and then have to rebuild it while debugging, I get this error when I try to use it again, after calling clear java
and creating a new object from my JAR file: 当我在MATLAB中使用我自己的JAR文件,然后在调试时必须重建它时,在我尝试再次使用它时,在调用clear java
并从我的JAR文件创建一个新对象后,我收到此错误:
java.lang.UnsatisfiedLinkError:
Native Library C:\deka\proj\java\ESPDF\dist\lib\jhdf5.dll
already loaded in another classloader
and I can't solve it without shutting down MATLAB and reopening, which is a pain in the neck. 如果不关闭MATLAB并重新打开,我无法解决这个问题,这是一个痛苦的问题。
What is this error and whose fault is it? 这个错误是什么,它的错是什么? (mine? MATLAB's? JHDF5 for not freeing the DLL or checking to see if it's already loaded) (我的?MATLAB的?JHDF5没有释放DLL或检查它是否已经加载)
In general, there is no way for Java code to unload a native dll. 通常,Java代码无法卸载本机dll。 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5075039 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5075039
Given that, once a dll is loaded, it's there for the lifetime of the JVM and the VM will ensure that it is loaded once and only once. 鉴于此,一旦加载了dll,它就会存在于JVM的生命周期中,并且VM将确保它只加载一次且只加载一次。
To answer the question of blame, I suppose it's the fault of the code that attempts to load the dll without checking if its already available. 为了回答责备问题,我想这是代码的错误,它试图加载dll而不检查它是否已经可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.