UnsatisfiedLinkError Trying to run OpenCV java code cross compiled


I'm beating my head against a wall here. There are a lot of very similar questions but none exactly on point. I'm sure the answer is staring me in the face.

I'm conducting my first OpenCV cross compile test. I set up OpenCV 3.1.0 in Eclipse on Windows 10. Code there runs fine. From there I created an executable .jar and FTP'd it to a raspberry pi 3 running Jessie.

I installed OpenCV 3.1.0 on the Pi including java support (on the third try). But I continue to get the same error.


import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;

public class Hello
   public static void main( String[] args )
      System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
      Mat mat = Mat.eye( 3, 3, CvType.CV_8UC1 );
      System.out.println( "mat = " + mat.dump() );


Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java310 in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1122)
        at Hello.main(Hello.java:9)

I've found opencv-java310.jar in /usr/local/share/OpenCV/java

And I have tried at the command line both with and without the -D parameter:

java -jar HelloEx.jar -D java.library.path=/usr/local/share/OpenCV/java

Thanks in advance

Show source
| java   | eclipse   | raspberry-pi   | opencv   2016-12-04 17:12 1 Answers

Answers ( 1 )

  1. 2016-12-06 07:12

    I'm not sure if you correctly set java.library.path, as in your starting post it is incorrect, please try use it as follows: java -Djava.library.path=/usr/local/share/OpenCV/java -jar HelloEx.jar and you also may check if it was set correctly in your java code by adding the following code (just to debug): System.out.println(System.getProperty("java.library.path"));

◀ Go back