Java: Hello World Program Example

Many coders first foray into software development began with two words, “Hello World”. In this tutorial we will demonstrate how to create a starter “Hello World” project in Java. Lets begin!

1. Install Eclipse IDE

Download eclipse from http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/lunasr1 and save it to your hard drive. Unzip the file. After unzipping the file, open it and run the eclipse.exe file. An Eclipse Workspace dialog may appear, click the Ok button.

2. Create New Project

To create a new Eclipse project click File->New->Project

hello-world-pic3

Eclipes File Menu, Create a new project by clicking File->New->Project

The New Project wizard will appear, select Java Project from the wizard options list and click the Next button.

hello-world-pic4

Eclipse New Project dialog, allows you to choose the type of project you will create.

Enter a project name, for example “hello-world” and click the Finish button.

hello-world-pic5

New Project Dialog accepts general information about the project that you will create. Such as project name.

The Open Associate Perspective? prompt may appear, Click the Yes button.

hello-world-pic6

Step 3. Create a Class

Lets create a Java Class file by first expanding the project in the Package Explorer window on the left side of the screen. Then right click on the src folder of the project and click New->Class

hello-world-pic7

The New Java Class dialog will appear. Enter package name -> com.letsbegin , for name enter -> Hello World. Select the checkbox public static void main(String[] args) and then click the Finish button.

hello-world-pic1

 Step 4. Write Code

A new Java file will automatically open in the eclipse editor.

hello-world-pic9

In the method main enter “System.out.println(“Hello World!!!”);”  as seen below:

1
2
3
4
5
public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello World!");
  }
}

6. Run Program

Right click on the project in the Package Explorer and click the Run button.

hello-world-pic8

You will see the message “Hello World!!!” in the as seen below.

hell-world-pic-last

 

Congrats! you have written a classic Hello World Java Program!

Leave a reply