0

Writing a simple program in Eclipse Kepler I am getting the following error:

Error: Could not find or load main class 

I already tried the options listed here, though the options the answers suggest do not seem to exist in Kepler. For example, there is no 'build Automatically' button to check as the accepted answer suggests. Here is the photographic proof: enter image description here

Code is as follows:

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

Unable to 'add' the main class under the 'projects' heading either. enter image description here

Community
  • 1
  • 1
WildBill
  • 9,143
  • 15
  • 63
  • 87

2 Answers2

0

Your main method should be:

public static void main(String[] args)

the String[] args is required as that is the method signature Java looks for when launching your Java program

For more information why String[] args is required: Why is String[] args required in Java?

Also, the "build automatically" reference is pointing to the project menu bar item, not in the window.

Community
  • 1
  • 1
Mike Koch
  • 1,540
  • 2
  • 17
  • 23
  • That's in the code, same error... – WildBill Feb 10 '14 at 03:44
  • Also, what is the 'project menu' bar? I do not see one in Kepler. Are you using Kepler? – WildBill Feb 10 '14 at 03:45
  • Yes i am using kepler. There should be a project dropdown where File/Refactor/Help etc. are located. The recommendations in the other stack overflow questions do exist in kepler as well. – Mike Koch Feb 10 '14 at 04:23
0

From the same Properties window Select Run/Debug

If your launching class doesn't exist in that list, you need to add it by clicking New - Java Application, then in the dialog Search for your class in the Main Class text field. That should give your project a Main launching class

And/OR try to go to Run as -> Run Configuration from the project context menu. In the Main Class text field put in the fully qualified name of the launching class

You may need to clean an build afterwards

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720