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

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

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

问题

  1. 我已经开始学习OpenCV Java并且这是我编写的用于测试OpenCV设置的程序
  2. ```java
  3. import org.opencv.core.Core;
  4. import org.opencv.core.CvType;
  5. import org.opencv.core.Mat;
  6. public class FirstProgram
  7. {
  8. public static void main(String args[])
  9. {
  10. System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
  11. Mat mat = Mat.eye(3, 3, CvType.CV_8UC1);
  12. System.out.println(mat.dump());
  13. }
  14. }

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

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

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

  • OpenCV版本:4.2.0
  • Eclipse:2019-03
  • JDK:13
  1. <details>
  2. <summary>英文:</summary>
  3. 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());
}
}

  1. But on running this, Eclipse shows the error:
  2. &quot;*Error: Could not find or load main class FirstProgram
  3. Caused by: java.lang.ClassNotFoundException: FirstProgram*&quot;
  4. I have already setup the [user libraries][1] and added the libraries to the [project folder][2]. (Screenshots linked)
  5. How do I resolve this issue ?
  6. - OpenCV version: 4.2.0
  7. - Eclipse: 2019-03
  8. - JDK: 13
  9. [1]: https://i.stack.imgur.com/TiwYu.jpg
  10. [2]: https://i.stack.imgur.com/kHTdg.jpg
  11. </details>
  12. # 答案1
  13. **得分**: 1
  14. Eclipse 2019-03(发布于20193月)对于Java 13(发布于20199月)来说过于陈旧。
  15. 请[升级][1]至当前版本(目前为Eclipse 2020-03)。
  16. [1]: https://stackoverflow.com/a/46273081/6505250
  17. <details>
  18. <summary>英文:</summary>
  19. Eclipse 2019-03 (released March 2019) is too old for Java 13 (released September 2019).
  20. Please [upgrade][1] to the current version (currently, Eclipse 2020-03).
  21. [1]: https://stackoverflow.com/a/46273081/6505250
  22. </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:

确定