Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error loading OpenCV with Maven

Hey, I am trying to import OpenCV from Maven repository. The dependency works because I can see OpenCV classes in Eclipse.

This is the dependency in Maven pom.xml:

<dependency> 
<groupId>nu.pattern</groupId> 
<artifactId>opencv</artifactId> 
<version>2.4.9-4</version> 
</dependency>

However, when I launch the program:

package helloworld;
import org.opencv.core.*;
public class Hello {

    public static void main(String[] args) 
    {
           nu.pattern.OpenCV.loadLibrary();
           //System.out.println("Hey World !");
           //Mat mat = Mat.eye(3, 3, CvType.CV_8UC1);
    }
}

I get this error when I try to load the library:

java.lang.NoSuchFieldException: sys_paths
at java.base/java.lang.Class.getDeclaredField(Class.java:2417)
at nu.pattern.OpenCV.loadLibrary(OpenCV.java:207)
at helloworld.Hello.main(Hello.java:7)

Also, I have jdk 12.0.1.

If you have any information about what is going on, or how to solve that please let me know !

Thank you in advance