"Java.lang.UnsatisfiedLinkError: no opencv_java320 in java.library.path"

Viewed 16327

I have a selenium test that when it finishes makes some operations with OpenCV. With IntelliJ IDEA it works fine, the operations process correctly, but when I try to execute through command line (for Jenkins use in the near future), I get the error mentioned above:

"Java.lang.UnsatisfiedLinkError: no opencv_java320 in java.library.path"

I read the other questions on here and I've set up the java.library.path to the path where the jar and dll files are, but the error still comes up and I'm running out of ideas.

Could you please help me?

Thanks!

5 Answers

This worked for me. I am using intellij on mac

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

public class Test {

 public static void main(String[] args){
    //System.loadLibrary(Core.NATIVE_LIBRARY_NAME); - REMOVE THIS
    nu.pattern.OpenCV.loadShared(); //add this
    Mat mat = Mat.eye(3, 3, CvType.CV_8UC1);
    System.out.println("mat = " + mat.dump());
 }
}

And dependency

<dependency>
   <groupId>org.openpnp</groupId>
   <artifactId>opencv</artifactId>
   <version>3.2.0-0</version>
</dependency>

If you are using STS/Eclipse or any IDE then follow the steps to getting solve your unsatisfiedlinkerror-no-opencv-java320 error.

Window -> Preferences -> User Libraries -> New -> create new Library Like attached Image

Note:- Jar location and Native Library Location (opencv/build/java/x64) should be exactly like this while creating the new library.

enter image description here

This working for me on intellij Idea :

  1. Open your project in intellij Idea,
  2. Go to File->ProjectStructure->Libraries then click + (Java)
  3. Then add the .dll file. In my case I had: \opencvFolder\build\java\x64\opencv_java320.dll
  4. Now go to File->Project Structure->Modules->Dependencies then click + (Jars or directories)
  5. Then add the opencv jar file. In my case I had: \opencvFolder\build\java\opencv-java320

And it worked ! Hope this will help :)

Related