How to resolve "Error: Could not find or load main class FirstProgram" while running OpenCV Java in Eclipse?

huangapple go评论71阅读模式
英文:

How to resolve "Error: Could not find or load main class FirstProgram" while running OpenCV Java in Eclipse?

问题

我已经开始学习OpenCV Java并且这是我编写的用于测试OpenCV设置的程序

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

但是运行这个程序时,Eclipse显示错误:
"错误:找不到或加载主类FirstProgram
原因:java.lang.ClassNotFoundException: FirstProgram*"

我已经设置了user libraries,并将库添加到project folder中。(链接到屏幕截图)

我应该如何解决这个问题?

  • OpenCV版本:4.2.0
  • Eclipse:2019-03
  • JDK:13

<details>
<summary>英文:</summary>

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: 
&quot;*Error: Could not find or load main class FirstProgram
Caused by: java.lang.ClassNotFoundException: FirstProgram*&quot;

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

How do I resolve this issue ?

- OpenCV version: 4.2.0 
- Eclipse: 2019-03 
- JDK: 13

  [1]: https://i.stack.imgur.com/TiwYu.jpg
  [2]: https://i.stack.imgur.com/kHTdg.jpg

</details>


# 答案1
**得分**: 1

Eclipse 2019-03(发布于2019年3月)对于Java 13(发布于2019年9月)来说过于陈旧。

请[升级][1]至当前版本(目前为Eclipse 2020-03)。

[1]: https://stackoverflow.com/a/46273081/6505250

<details>
<summary>英文:</summary>

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

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


  [1]: https://stackoverflow.com/a/46273081/6505250

</details>



huangapple
  • 本文由 发表于 2020年4月10日 23:59:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/61144008.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定