Ask Your Question

leboshi's profile - activity

2015-03-09 11:19:48 -0600 asked a question OpenCV desktop Java bindings on Windows 7 - UnsatisfiedLinkError

I'm new to OpenCV and tried installing the desktop Java bindings, but my code fails when I try to instantiate anything from the native library included in the build. My code is pretty basic:

import org.opencv.objdetect.CascadeClassifier;

public final class OpenCVTest {
    static {
        System.load("C:\\Program Files\\opencv\\build\\java\\x64\\opencv_java2411.dll");

    public void process(String s) {
        CascadeClassifier cc = new CascadeClassifier();
        CascadeClassifier faceDetector = new CascadeClassifier("C:\\Program Files\\opencv\\sources\\data\\haarcascades\\haarcascade_frontalface_alt.xml");

    public static void main(String[] arguments) {
            OpenCVTest test = new OpenCVTest();
            for (String s : arguments)

It compiles fine, but when I run it --

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.objdetect.CascadeClassifier.CascadeClassifier_0()J
        at org.opencv.objdetect.CascadeClassifier.CascadeClassifier_0(Native Method)
        at org.opencv.objdetect.CascadeClassifier.<init>(
        at OpenCVTest.process(
        at OpenCVTest.main(

I have lines in there trying the single-string and the nullary constructors because both fail with the same error (but with different line numbers in

I'm running 64-bit Java 8 update 40 (1.8.0_40-b25), same for my JDK and JRE, on Windows 7 SP1 x64.

I've included the call to load the DLL in a static block, so it should be loading once and exactly once before any constructors. I'm calling System.load() to the direct path instead of System.loadLibrary() to be 100% clear about what DLL I want to load and from where. I've tried mangling the path to the DLL, and Java gives me a different error that it can't find the DLL, so I know Java at least SEES opencv_java2411.dll. I am using corresponding versions of the JAR file with the bindings and the DLL (both 2.4.11 right now, though I've tried versions 2.4.10, 2.4.11, and 3.0.0 beta, all with this same error).

Any leads would be greatly appreciated. Thanks!