Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse : Java : OpenCV : "The import org cannot be resolved."

I compiled OpenCV on Linux (Mint 19 Tara), I used this tutorial: https://docs.opencv.org/2.4/doc/tutorials/introduction/desktop_java/java_dev_intro.html

Then I tried to use the library like that: https://docs.opencv.org/3.4/d1/d0a/tutorial_java_eclipse.html

But in the imports I get an error: "The import org cannot be resolved."

What can I do wrong? Here is the code I used:

package com.thegergo02.facedetection;

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() );
   }
}

Package Explorer screenshot

The compile was successful, no errors, i had Java, Ant, everything.

Java version: jdk-11.0.1 Ant version: 1.10.3

like image 338
thegergo02 Avatar asked Aug 03 '26 03:08

thegergo02


1 Answers

In the default package, delete the file module-info.java.

The tutorial is based on Java 6 without the Java Platform Module System (JPMS) in mind which can (but does not have to) be used since Java 9.

If using JPMS, the dependency to the OpenCV module must be explicitly defined in the module-info.java file to make it accessible.

like image 70
howlger Avatar answered Aug 04 '26 15:08

howlger