0

I have started learning OpenCV Java and this is the program I have written to test the OpenCV setup:

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
public class FirstProgram 
{
    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.dump());
    }
}

But on running this, Eclipse shows the error: "Error: Could not find or load main class FirstProgram Caused by: java.lang.ClassNotFoundException: FirstProgram"

I have already setup the user libraries and added the libraries to the project folder. (Screenshots linked)

How do I resolve this issue ?

  • OpenCV version: 4.2.0
  • Eclipse: 2019-03
  • JDK: 13
the-unreal
  • 79
  • 1
  • 1
  • 10
  • Eclipse 2019-03 (released March, 2019) is too old for Java 13 (released September, 2019). Please [upgrade](https://wiki.eclipse.org/FAQ_How_do_I_upgrade_Eclipse_IDE%3F#Always_enable_major_upgrades) (the current version is Eclipse 2020-03). – howlger Apr 10 '20 at 16:30
  • Are there any entries for the project in the Problems View? – nitind Apr 10 '20 at 19:29
  • @howlger It seems you were right. It's working now that I have upgraded the IDE. Thanks. – the-unreal Apr 11 '20 at 07:19
  • @nitind The problem was resolved by upgrading the IDE. Thanks. – the-unreal Apr 11 '20 at 07:20

1 Answers1

1

Eclipse 2019-03 (released March 2019) is too old for Java 13 (released September 2019).

Please upgrade to the current version (currently, Eclipse 2020-03).

howlger
  • 31,050
  • 11
  • 59
  • 99