HaBo
HaBo

Reputation: 14317

Eclipse Error: Could not find or load main class

I am new to Java. I have created a simple console application

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

I am using Eclipse IDE for Java Developers Version: Luna Service Release 1 (4.4.1)

When I hit run for the application I get "Error: Could not find or load main class" When I searched for similar issues online, most of them are suggesting to edit , I am not sure what am I supposed to change there in my case

Here is my classpath file. enter image description here enter image description here

Upvotes: 0

Views: 1056

Answers (1)

Elliott Frisch
Elliott Frisch

Reputation: 201507

You can't run a .classpath file. Right click on Main.java, and then select "Run As > Java Application". Of course, you'll need to fix the compiler errors (the red X) that are displayed under the Main.java tab in your screen shot. Unfortunately, we can't see those errors. The code posted above

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

is fine, so Main.java must have some other code in it.

Upvotes: 2

Related Questions