i get this error after running my project with javacv library.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java2411 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at webcam.cam.main(cam.java:181)
You can use this below way:
public static void loadOpenCVLib(String path) throws Exception {
File lib_dir = new File(path);
System.setProperty("java.library.path", lib_dir.getAbsolutePath());
Field sys_paths = ClassLoader.class.getDeclaredField("sys_paths");
sys_paths.setAccessible(true);
sys_paths.set(null, null);
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
// it is for the ffmpeg name
String[] list = lib_dir.list();
assert list != null;
String ffmpeg_dll_file_name = null;
for (String s : list) {
if (s.contains("ffmpeg")) {
ffmpeg_dll_file_name = s.substring(0, s.indexOf("."));
}
}
System.loadLibrary(ffmpeg_dll_file_name);
}
And now create a folder in some place and name it opencv_lib
e.g: D:\opencv_lib
, and then put the opencv dll and ffmpeg dll files inside this folder, and then when running the program first of all call the method above e.g:
loadOpenCVLib("D:\\opencv_lib");
Now it will be OK.
Note: It will be better to download and use the latest version of OpenCV