I'm trying to compile and run a simple example of Java code using OpenCV library, on Ubuntu 14.04 64bits, found in OpenCV's documentation: Java OpenCV Documentation
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.CvType;
import org.opencv.core.Scalar;
class SimpleSample
{
static
{
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}
public static void main(String[] args)
{
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());
}
}
Since it is just a simple test, I really don't want to use any sophisticated building system. So I'm compiling with the following command:
javac -cp "/usr/share/OpenCV/java/opencv-248.jar" SimpleSample.java
However I'm unable to run the application, because when I call: java SimpleSample
I face the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/opencv/core/Core
at SimpleSample.<clinit>(SimpleSample.java:10)
Caused by: java.lang.ClassNotFoundException: org.opencv.core.Core
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
Can someone help me running this application?