UnsatisfiedLinkError when using Maven

989 views
Skip to first unread message

Ivan Mushketik

unread,
May 31, 2012, 2:18:37 PM5/31/12
to jav...@googlegroups.com
Hello.

I am writing an application using JavaCV in Netbeans 7.1 using Maven.
Unfortunately when I run a simple example like this:
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;

public class JavaCVTest {
    public static void main(String[] argv) {
        System.out.println(System.getenv("java.library.path"));
        String filename = "/home/proger/cat.png";
        String resultFile = "/home/proger/catNew.png";
        IplImage image = cvLoadImage(filename);
        if (image != null) {
            cvSmooth(image, image, CV_GAUSSIAN, 3);
            cvSaveImage(filename, image);
            cvReleaseImage(image);
        }
    }
}

I receive an exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
    at java.lang.Runtime.loadLibrary0(Runtime.java:845)
    at java.lang.System.loadLibrary(System.java:1084)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:444)
    at com.googlecode.javacpp.Loader.load(Loader.java:368)
    at com.googlecode.javacpp.Loader.load(Loader.java:315)
    at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:131)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at com.googlecode.javacpp.Loader.load(Loader.java:334)
    at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:96)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at com.googlecode.javacpp.Loader.load(Loader.java:334)
    at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:91)
    at uk.ac.glyndwr.imageSpamFilter.JavaCVTest.main(JavaCVTest.java:16)

I installed OpenCV correctly and run examples that is bundled with its source code and everything was fine.
I also tried to run an application from JavaCV examples without Maven and it also worked fine.

I added javacv dependencies to my Maven pom file in the following way:
        <dependency>
            <groupId>com.googlecode.javacv</groupId>
            <artifactId>javacv</artifactId>
            <version>0.1</version>
        </dependency>       
        <dependency>
            <groupId>com.googlecode.javacpp</groupId>
            <artifactId>javacpp</artifactId>
            <version>0.1</version>
        </dependency>
       
        <dependency>
            <groupId>com.googlecode.javacv</groupId>
            <artifactId>jniOpenCV</artifactId>
            <version>0.1</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/javacv-linux-x86.jar</systemPath>
        </dependency>

What can be the reason of the problem?
I am using Ubuntu 11.10 and Java 7.

Thank you in advance.

P.S. My java.library.path value is null in this application. Can this cause the problem?

Samuel Audet

unread,
May 31, 2012, 9:16:50 PM5/31/12
to jav...@googlegroups.com
Hello,

Your classpath is obviously missing the
/com/googlecode/javacv/cpp/libjniopencv_core.so file. Put it in your
classpath, as explained in the README.txt file. As to what you could
include in the pom.xml file, again as mentioned in the README.txt file,
you could try to use something like used for ProCamCalib and ProCamTracker:
http://code.google.com/p/javacv/source/browse/procamcalib/pom.xml
http://code.google.com/p/javacv/source/browse/procamtracker/pom.xml

Samuel

Ivan Mushketik

unread,
Jun 1, 2012, 7:14:58 AM6/1/12
to jav...@googlegroups.com
Sorry, I didn't see this example.
Now everything works just fine.
Thank you very much.

Samuel Audet

unread,
Jun 1, 2012, 10:12:54 AM6/1/12
to jav...@googlegroups.com
Great to hear that!

Samuel

Gabriela Bosetti

unread,
Jun 15, 2012, 11:56:00 AM6/15/12
to jav...@googlegroups.com
Hi Samuel! Excuse all my questions! Where is that readme.txt? Is this? http://code.google.com/p/javacv/source/browse/procamcalib/README.txt
Because I read you suggest to read this document, but I can't find nothing about classpath there
Reply all
Reply to author
Forward
0 new messages