Most of the programming languages are learned by starting with writing a simple program which prints simple “Hello World”. In this article we will learn how to write a simple Java program which prints “Hello World” text on our system console. We are using Eclipse IDE for creating our program.

Following are the steps to create “Hello World” Java program:

  • Create a new java project.
  • Print “Hello World” to the system console.
  • Run the program.

Create a new java project

Create a new Java project from File > New > Java Project as shown below:

java hello world1

This opens up New Java Project configuration window. Enter the Project name and click on Finish button.

java hello world2

Now our Java Project is ready. Next we have to add a Java class to print “Hello World”. create new Java class from Right Click on Java project > New > Class as shown below.

java hello world3

This will open up Java class configuration window. Enter package name and class name as shown below and click on Finish button. Also make sure to check the option public static void main(String[] args) option under section Which method stubs would you like to create?.

java hello world4

 

Print “Hello World” to the system console

Now our Java project structure and Java class is ready. Modify the HelloWorld.java content with following code. Here we have added a line (System.out.println(“Hello World”);) to print “Hello World” on console.

package com.asb;
public class HelloWorld {
 public static void main(String[] args) { 
  // TODO Auto-generated method stub 
  System.out.println("Hello World"); 
 }
}

 

Run the program

Finally, Run the program from Run button, shown on the tool bar of the eclipse IDE as shown below:

java hello world5

Now our first “Hello World” java program is ready, which prints the “Hello World” to system’s console:

java hello world6

Version Details : Eclipse Neon.2 Release (4.6.2)

Also read: