I have problems adding openCV to the buildpath of my eclipse-project. I have followed the instructions in the tutorial on this site: http://docs.opencv.org/2.4.4-beta/doc/tu
I have found the solution. The tutorial skips the step, where one has to add a dll to the "native build path". The dll is located in "opencv/build/java/x86" for 32-bit java i guess. although i dont know why this is the case. Would be nice, if someone could explain that.
I had the same problem.
It happened because I had a mistake with the 'Native library location' configuration:
Goto Eclipse -> Window -> Preferences:
Goto User Libraries:
Make sure that your native library location path is (change c:/opencv-2.4.9 to your own opencv folder):
C:/opencv-2.4.9/build/java/x64
and not:
C:/opencv-2.4.9/build/x64
(I missed the /java folder...)
Change the code to System.loadLibrary("opencv_java244")
hope you would set the native path to correct folder and opencv jar has set in build path
For me, Eclipse > external jar > native library config = opencv/build/lib worked
The OpenCV java library is correctly linked to your Eclipse project.
The problem is the OpenCV native library which is not in the java.library.path
. The exception is thrown by the line
static{ System.loadLibrary("opencv_java244"); }
which link the java library to the native one.
When you install OpenCV on your computer, it will also install a native dll
library somewhere on your system, and when you call the System.loadLibrary
, you tell java to search and load this library.
Your current problem is Java can not find this library in your System, either because the library is not in one of the java.library.path
folders, or because you have not OpenCV installed (also take a look at the version, maybe you have not the 2.4.4 because the last is 2.4.5, in which case you will have to adapt the String).
I just noticed that your exception is about "opencv-java2.4.4". Be sure to have the right spelling of the form "opencv_java244", in your System.loadLibrary
call.
I also redirect you to one of my answer, which is related to JavaCV, but that explain in more details what is going under.
I found a solution. The actual dll is located in the openCV\opencv\build\java\x64\
folder. In my case, its name is opencv_java247.dll
, so I have changed System.loadLibrary("opencv_java244")
to System.loadLibrary("opencv_java247")
in my java code. I also put the native library location as E:/Sagar_tools/tools/openCV/opencv/build/java/x64
(which is my full path to the dll).