Ask Your Question

OpenCV Run on Tomcat

asked 2015-09-16 11:34:01 -0500

Rafalsonn gravatar image

Hello, I've made an application which uses OpenCV, and now I want to run it on Tomcat. I'm now trying to set Tomcat to Work, this is the simple code to check is it working on tomcat:

String libopencv_java = "C:\\eclipse\\workspace\\tomcat_try\\opencv_java300.dll";
        LOG.debug("OpenCV Loaded");

        System.out.println("Welcome to OpenCV " + Core.VERSION);
        Mat m = new Mat(5, 10, CvType.CV_8UC1, new Scalar(0));
        System.out.println("OpenCV Mat: " + m);
        Mat mr1 = m.row(1);
        mr1.setTo(new Scalar(1));
        Mat mc5 = m.col(5);
        mc5.setTo(new Scalar(5));
        System.out.println("OpenCV Mat data:\n" + m.dump());

When I'm executing the code on tomcat the result is:

Caused by: java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat(IIIDDDD)J at org.opencv.core.Mat.n_Mat(Native Method) at org.opencv.core.Mat.<init>(

Can somebody help me? I've added the opencv300.jar file to the build path,

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-09-20 10:31:20 -0500

RolandC gravatar image

updated 2015-09-21 01:12:18 -0500

My guess is that the OpenCV library isn't loaded. If you'd like to do it with loadLibrary you must specify a library path when you start the VM:


Also, the libary must be without the ".dll" extension.

In other words:

OpenCV's looks like this:

public static final String NATIVE_LIBRARY_NAME = getNativeLibraryName();
private static String getNativeLibraryName() { return "opencv_java300"; }

Then you load the library like this:

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-09-16 11:34:01 -0500

Seen: 1,564 times

Last updated: Sep 21 '15