简体   繁体   English

出现错误:java.lang.UnsatisfiedLinkError:本机库C:\\ opencv \\ build \\ java \\ x64 \\ opencv_java300.dll

[英]getting error : java.lang.UnsatisfiedLinkError: Native Library C:\opencv\build\java\x64\opencv_java300.dll

I am running a servlet program to read an image using opencv, 我正在运行servlet程序以使用opencv读取图像,
getting error : 出现错误:

java.lang.UnsatisfiedLinkError: Native Library C:\opencv\build\java\x64\opencv_java300.dll already loaded in another classloader . When restarting the IDE it works fine.

I loaded System.loadLibrary ( Core.NATIVE_LIBRARY_NAME ) ; 我加载了System.loadLibrary ( Core.NATIVE_LIBRARY_NAME ) ; in servlet only ones. 在servlet中只有一个。

Can anybody suggest a solution for how to unload it. 任何人都可以提出有关如何卸载它的解决方案。 And also anybody know how to read an image from browser using opencv in java.? 还有谁知道如何在Java中使用opencv从浏览器读取图像?

It is because the library is not in the system path, it needs to first added to the system path, then load. 这是因为该库不在系统路径中,因此需要先将其添加到系统路径中,然后再进行加载。 First extract the OpenCV to C drive something like this c:\\opencv\\... then use this code below to during initializing, it will automatically load the OpenCV lib in windows environment. 首先将OpenCV提取到C驱动器,例如c:\\opencv\\...然后在初始化期间使用以下代码,它将在Windows环境中自动加载OpenCV库。

public static void loadOpenCV_Lib() throws Exception {
    String model = System.getProperty("sun.arch.data.model");
    String libraryPath = "C:/opencv/build/java/x86/";
    if(model.equals("64")) {
        libraryPath = "C:/opencv/build/java/x64/";
    }
    System.setProperty("java.library.path", libraryPath);
    Field sysPath = ClassLoader.class.getDeclaredField("sys_paths");
    sysPath.setAccessible(true);
    sysPath.set(null, null);
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}

And also it will automatically detect the system model and load the lib according to the system model. 并且它将自动检测系统模型并根据系统模型加载lib。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.UnsatisfiedLinkError:C:\\ opencv \\ build \\ java \\ x64 \\ opencv_java310.dll: - java.lang.UnsatisfiedLinkError: C:\opencv\build\java\x64\opencv_java310.dll: OpenCV java.lang.UnsatisfiedLinkError - OpenCV java.lang.UnsatisfiedLinkError java.lang.UnsatisfiedLinkError opencv-contrib - java.lang.UnsatisfiedLinkError opencv-contrib Eclipse中的OpenCV 3.0.0 java.lang.UnsatisfiedLinkError - OpenCV 3.0.0 java.lang.UnsatisfiedLinkError in Eclipse OpenCV 4.3.0 java.lang.UnsatisfiedLinkError 在 Eclipse - OpenCV 4.3.0 java.lang.UnsatisfiedLinkError in Eclipse Android java.lang.UnsatisfiedLinkError与本机库 - Android java.lang.UnsatisfiedLinkError with native library 调用本机库函数,得到java.lang.UnsatisfiedLinkError? - Calling native library functions, getting java.lang.UnsatisfiedLinkError? 获取本机层版本时出错:java.lang.UnsatisfiedLinkError:java.library.path中没有sapjco3 - Error getting the version of the native layer: java.lang.UnsatisfiedLinkError: no sapjco3 in java.library.path 无法加载本机库。 错误:java.lang.UnsatisfiedLinkError - Cannot load native library. Error: java.lang.UnsatisfiedLinkError “Java.lang.UnsatisfiedLinkError:java.library.path 中没有 opencv_java320” - “Java.lang.UnsatisfiedLinkError: no opencv_java320 in java.library.path”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM