英文:
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:
"*Error: Could not find or load main class FirstProgram
Caused by: java.lang.ClassNotFoundException: FirstProgram*"
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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论