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

thegergo02 :

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

howlger :

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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=102954&siteId=1