Hello world java program

(Last Updated On: February 23, 2019)

Creating Hello world java program with steps to create project, package and class in eclipse editor with important points explained.

Steps to Create a first Hello World program in java in Eclipse IDE

  • On top menu, Click File -> New -> Java Project
  • Enter a project name whatever you want. For example, JavaCourse. Click Finish.
  • On left pane (Package Explorer) you should see the project name JavaCourse.
  • Expand the JavaCourse by clicking on > symbol. You should see “src” folder.
  • Right click on src folder, go to New->Package and click on it. A window will be popper up to create package. Give any name to package. For example, basic.
  • Below src folder you should see package named basic.
  • Right click on basic package. Go to New -> Class and click on it. A window will be popped up. There is a Name box. Write your class name there. For example, HelloWorld. Generally, class name should start with capital letter.
  • On this windows, you should find “which method stubs would you like to create?”. Tick the check box before public static void main(String[] args)
  • Click Finish, you should see below code.


Hello world program example


You can write System.out.println(“Hello World”); in main() method as below.” // TODO Auto-generated method stub” in above program is just a comment that you can remove.

Save the file and run the program by clicking green arrow button on top menu. Hello world string will be printed on console screen. Generally seen at bottom of the eclipse.

Here is the output of above program

Hello World


Now you learned how to create a hello world program in java.

Special Notes:

  • It is mandatory to have main() method to run an application/program. Because compiler find main method first to execute a program. If you don’t have the main() method, then compiler will not complain but will not give option to execute the program.



  • public class: class is public so it can be accessible from anywhere in the project.
  • static: method can be called using class name without creating object of the class.
  • void: method does not return anything.
  • main():method is the starting point of program execution.