问题描述
我正在使用一个我自己的JAR文件,它使用一个Java库(JHDF5),它依次通过JNI使用一个dll。当我在MATLAB中使用我自己的JAR文件,然后在调试时必须重建它,当我尝试再次使用它之后,在调用 clear java
并创建我的JAR文件中的一个新对象: java.lang.UnsatisfiedLinkError:
本地库C:\deka\\ \\proj\java\ESPDF\dist\lib\jhdf5.dll
已经加载到另一个类加载器
我无法解决它,而不关闭MATLAB和重新打开,这是一个痛苦的脖子。
这是什么错误和谁的是错吗(我的?MATLAB的?JHDF5不释放DLL或检查是否已经加载)
一般来说, Java代码无法卸载本地DLL。
鉴于一旦加载了dll,JVM的生命周期就在那里,VM将确保它被加载一次只有一次。
为了回答这个问题,我想这是代码的错误,试图加载dll,而不检查它是否已经可用。 p>
I'm using a JAR file of my own, which uses a Java library (JHDF5), that in turn uses a dll through JNI. 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:
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.
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)
In general, there is no way for Java code to unload a native dll.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.
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.
这篇关于java.lang.UnsatisfiedLinkError:已经加载到另一个类加载器中的本地库{____。dll}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!