0

I am using eclipse and trying to run hello world program. I keep getting this error when I try to run the program:

Error: Could not find or load main class HelloWorld

I do have the jdk installed and eclipse is pointing to C:\Program Files\Java\jdk1.7.0_80.

Is there anything else am I missing?

public class HelloWorld {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        System.out.println("Hello world!");

    }

}
user1471980
  • 10,383
  • 47
  • 132
  • 225
  • 3
    You might need to specify the main class in your run configuration: http://stackoverflow.com/questions/17397440/how-to-setup-main-class-in-run-configurations-in-eclipse – Daniel Figueroa Feb 12 '16 at 15:02
  • create class name as HelloWorld as you have created while building project better dont change names of generated class names – Akhil Feb 12 '16 at 15:04
  • When you run this from Eclipse, by Right click on the source file and Choosing `Run as Java Program`, it will run fine and print – soorapadman Feb 12 '16 at 15:10
  • You can check this link for a reference:http://javarevisited.blogspot.in/2015/04/error-could-not-find-or-load-main-class-helloworld-java.html – soorapadman Feb 12 '16 at 15:11
  • @user101, I tried to run it as java program, still the same error. I need to know if my eclipse is configured correctly? – user1471980 Feb 12 '16 at 15:22

1 Answers1

0

I found the problem folder name and the java class name needs to be same as HelloWorld. I did have a typo in the folder name.

user1471980
  • 10,383
  • 47
  • 132
  • 225