Exporting Executable jar file that uses opencv

百般思念 提交于 2019-11-29 12:15:43

Short answer

You must install OpenCV (as mentioned in JavaCV requirements) and JavaCV on the system in order to use JavaCV. As you probably installed them for development on your computer the application work, but the other machine probably has not them installed and thus the jar does'nt work.

Long answer

The problem is not the JavaCV library, which appears to be correctly included into your jar as shown by the lines:

at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
at com.googlecode.javacpp.Loader.load(Loader.java:489)
at com.googlecode.javacpp.Loader.load(Loader.java:431)
at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:136)

The fact is JavaCV is build on top of OpenCV. OpenCV being a C++ library, the only way to use it from Java is to use JNI calls.

JNI require two components:

  • A java library (usually with extension *.jar) containing java method that calls native library
  • A native library (usually with extension *.so for linux or *.dll for windows) that "do the work", in this case that "use OpenCV library"

The first one is provided by JavaCV and included into your jar application. The second one is system dependent (Os, architecture, ...) and must be into the java library path.

This is the actual error: it can not find libjniopencv_core.so into java.library.path. The jniopencv_core library is provided by JavaCV too but is installed somewhere on the system (/usr/lib/ for instance) and thus not included into the final jar.

Even if you find a way to include it into the final application, this library will need to use OpenCV libraries which are not installed on the system too. To summarize the needs:

  1. JavaCV java library, that will call (with JNI):
  2. JavaCV native library, that will use:
  3. OpenCV libraries, that will really do the work.

Without one of this point the application will not work. Thus OpenCV and JavaCV must be installed into the system.

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