Error loading OpenCV with Maven

asked 2019-06-14 02:48:12 -0500

Rafutek gravatar image

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:


However, when I launch the program:

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

    public static void main(String[] args) 
           //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(
at nu.pattern.OpenCV.loadLibrary(
at helloworld.Hello.main(

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

edit retag flag offensive close merge delete


import OpenCV from Maven repository.

opencv does not maintain any maven repository. (and we probably can't help with 3rd party efforts there)


stone age, dead since 6 years. don't use it.

berak gravatar imageberak ( 2019-06-14 02:52:11 -0500 )edit

I changed the version with 3.4.2, last version in Maven repository:

It still doesn't work with nu.pattern.OpenCV.loadShared() method, raises these errors: Exception in thread "main" java.lang.ExceptionInInitializerError Caused by: java.lang.RuntimeException: Failed to get field handle to set library path ... 3 more

But with nu.pattern.OpenCV.loadLocally() it works!

What do you recommend, loading locally the 3.4.2 version as I did, or install all the library (which is really long to be honest) and link it locally with Maven? Or maybe another alternative...

Thank you

Rafutek gravatar imageRafutek ( 2019-06-14 03:18:32 -0500 )edit

again, you have to complain with the maintainer of that maven repo, we can't do much about it here

Or maybe another alternative...

the official way is to build from src

berak gravatar imageberak ( 2019-06-14 03:24:11 -0500 )edit