Error: Could not find or load main class

Error: Could not find or load main class

当我 运行 我的程序说:

Error: Could not find or load main class Hello world

每个设置我都做了几次,但我得到了相同的结果。 赢得 8.1 64 位 路径设置ok eclipse jre 设置正常

public class newproject1
{
    public static void main(String[] args) {
        System.out.println("Hello World! ");
    }
}

Error: Could not find or load main class newproject1

我猜你的 Hello world class 没有定义 main 方法。格式为:

public static void main(String[] args)
{
    //in here you put what you want the program to do
    System.out.println("Hello World");
}

今天我刚在 Eclipse indigo 中得到 "Error: Could not find or load main class"。我不知道你的问题是否相同。在我的例子中,我的项目代码是原始代码的备份,我将备份文件夹命名为 "x86 31 mayıs yedek"。 "mayıs" 是土耳其语单词,软件中通常存在与土耳其语字符及其语言设置相关的问题。这个词中的“ı”是土耳其语中的特殊字符。

简单地说,我从 eclipse 中删除了项目,我通过删除任何非英语的额外字符来更改备份文件夹的名称。然后我再次导入项目,重建它并且它工作了。希望这有帮助。

我遇到了同样的问题,在尝试了一些不同的方法后,终于通过重新设置工作区解决了我的问题!
文件->切换工作区->其他
并重新设置!