Exception in thread “main” java.lang.UnsatisfiedLinkError: no opencv_java249 in java.library.path

偶尔善良 提交于 2019-12-04 13:03:54

The problem is that the native opencv library cannot be found because it is not in the java.library.path (it is a native library and it should not be in usual java classpath, but it must be in the java.library.path).

Your opencv distribution should contains:

  • a java library : opencv249.jar. This library is mainly a java to native library with jni stuff allowing you to do native calls from java code. It must be in the classpath (and according the error you have and your explanations : it is on your classpath --> everything is ok here)

  • a native library named libopencv_java249.so and this must be in your java.library.path . Obviously : it is not : the UnsatisfiedLinkError is the symptom of a missing native library. To include this native library: start your java program with the following parameter:

    -Djava.library.path=/path/to/the/directory/of/ibopencv_java249.so

Ognjen Mišić

Another possible solution which worked for me on Ubuntu: Instead of setting the JVM parameter to the exact libopen.so file, try setting it to the folder:

-Djava.library.path=/opencv-3.2.0/opencv/build/lib/
DK Rajput

I had the same issue on ubuntu 14.o and I struggled a lot and found this solution.

  1. use below line to print your Native lib path: System.out.println(System.getProperty("java.library.path"));
  2. if you are adding external openc4-version.jar then, in eclipse open BuildConfigurationPath->Library->opencv249.jar->Native Library and click edit and choose external folder which will be located inside /home/dav/Downloads/opencv-2.4.9/build/lib

Before this I built opencv as they metioned in java-opencv quickstart tutorial by creating build folder inside opencv unziped folder then ran 2 commands 1.cmake -DBUILD_SHARED_LIBS=OFF .. if you get error then check make installed or not 2.make -j8

Done.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!