Eclipse Java - Hello World Application / Program

Share |

This article will create a Java project and a Java class in Eclipse that will print "Hello world!" in the console when run.

1) Open the Java Perspective
If you're not already in the Java perspective, in the main menu select Window > Open Perspective > Java or click on the "Click to Perform" link below.

2) Create a Java Project
Before creating a class, we need a project to put it in. In the main toolbar, click on the New Java Project button. Enter HelloWorld for the project name, then click Finish.

3) Create your HelloWorld Class
The next step is to create a new class. In the main toolbar again, click on the New Java Class button. Enter HelloWorld for the class name, select the checkbox to create the main() method, then click Finish.

4) Add a Print Statement
Now that you have your HelloWorld class, in the main() method, add the following statement:

System.out.println("Hello world!");
Then save your changes; the class will automatically compile upon saving.

5) Run your Java Application / Program

To run your application, right-click on your class in the Package Explorer and select Run As > Java Application. The Console view should appear at the bottom and display the "Hello, world!" output.

Congratulations! You have successfully created a Hello World application!

Share |

Core Java - Hello Word Program / Application

Share |

Here is the first program / application in Java, which is known as Hello World! program / application of Java.


  • Open Notepad or Textpad or any similar Text Editor
  • Create New file in that and write following code in that:

  • public class HelloWorld

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


  • Now save this file as (e.g you have saved at c:\test\ (In Java you should give file name as .java, in this case HelloWorld is the class name so we save it as
  • Now go to Command prompt
  • Change the directory of the command prompt to where you have saved
  • e.g.
    cd c:\test
  • Here type the command javac <java file name>
  • javac
  • This command will compile the Java file
  • Now to run this program give command java <class name which has main method>
  • java HelloWorld
  • This program will run and give output as follows:
  • Hello world!
  1. In the above program public class HelloWorld defines the class name in Java. Declaring public as access modifier means it is accessible outside.
  2. The line public static void main(String[] args) is the method which will be called first by the JVM when your try to run any application or program is java.
  3. We must declare this method as public since it will be called by JVM
  4. We must declare this method static since JVM will call this method by class name
  5. The main method always have arguments String[] this stores command line arguments if any

Share |

Hot Topics

My Headlines