当前位置: 代码迷 >> 综合 >> java.lang.UnsatisfiedLinkError: Native Library * already loaded in another classloader
  详细解决方案

java.lang.UnsatisfiedLinkError: Native Library * already loaded in another classloader

热度:20   发布时间:2023-12-12 22:29:49.0

java加载动态链接库有时会报异常如下,主要是因为java中不允许一个动态链接库被加载两次

java.lang.UnsatisfiedLinkError: Native Library D:\opencv\build\java\x64\opencv_java249.dll already loaded in another classloader

解决方案为:可将加载动态链接库的代码放到java的静态代码区中,代码如下:

static {try{System.out.println("Load Dll!");System.loadLibrary("opencv_java249");}catch(Exception e){e.printStackTrace();System.out.println("Load DLL!");}}

java的静态代码区和System.load的介绍可参考其他文章:

http://blog.csdn.net/quincuntial/article/details/50293039

http://blog.csdn.net/quincuntial/article/details/50215663

  相关解决方案