且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误:在Eclipse中找不到或加载主类

更新时间:2022-10-22 17:13:41

Eclipse不支持在项目名称中使用冒号或连字号。冒号似乎打破了处理编译的方式。



可以通过在项目的名称中不使用冒号来解决问题。



如注释中所述,这可能是Java 6的一个错误。它在Java 7中已修复。


I'm having trouble running a project in Eclipse 4.2. I have a Java program with one class titled Conversion. Eclipse builds the project fine. I'm able to run the program from the command line by navigating to /bin/ in the project's folder that's in the workspace and typing java Conversion.

However, when I try to run the program from Eclipse, I am shown Error: Could not find or load main class Conversion in the console.

The project name is 10.12.12: Project.

Eclipse does not support the use of a colon or hyphen in project names. Colons appear to break the way it handles compilation.

The issue can be fixed by not using a colon in the project's name.

As noted in the comments, this may be a fault of Java 6. It is fixed in Java 7.