If you get this error:
Exception in thread "main"
java.lang.UnsatisfiedLinkError: no opencv_java in java.library.path
It probably means you are shooting from the hip, programming by brownian motion, trying to get openCV to work. Like trying to figure out how an airplane works in flight by pressing all the buttons furiously. You're going to have a bad time.
What the error means:
Eclipse is telling you that the jar file can't find libraries it needs to do its job. So naturally it's not going to work until you make them available. You've got to find a tutorial on "how to build openCV from source" on your particular platform: (windows, mac, linux, etc), (32bit, 64bit, etc).
Basically, you glossed over the 'Native library location' settings, or didn't set them correctly, and so the jar can't find its support libraries written in C
.
How do fix it, thousand foot view:
- Download the source code for openCV for your operating system.
- Follow the directions to build openCV from source.
- Copy the jar into a lib directory in your Java project.
- Configure the jar to look for its native libraries by setting the "native library location" to the
build/lib
directory under the path where you built openCV from source.
- Clean build the java project, and the UnsatisfiedLinkError should go away.
This blog talks about the steps above in step-by-step detail: https://udallascs.wordpress.com/2014/03/30/adding-opencv-and-configuring-to-work-with-eclipse-and-java/
Why can't this just be a simple jar?
Because most of openCV is written in the C
programming language. And the jar file you are using is just a window into that C world. So it's a rube Goldberg machine. You'll see these sorts of things all over the place in the real work world, so pay attention, you are getting an education here.