Technologies used in this article :

  1. JDK 1.6

  2. Eclipse 3.7

JDK Installer : Download from JDK 1.6.
Eclipse Installer : Download from Eclipse 3.7.

 

1. Create Java Project

Select from the menu File --> New --> Java Project.

Create java project

Enter "HelloWorld" as the project name. Keep rest of the settings as it is as shown in the following screenshot.

Enter project name

Click "Finish" button and Eclipse IDE will generate the java project automatically.

 

2. Create Java Package

Right click on 'src' folder and select from context menu New --> Package.

Create java package

Write 'com.srccodes.example' in the 'Name' field and click "Finish" button.

Write package name

 

3. Create Java Class

Right click on 'com.srccodes.example' package and select from context menu New --> Class.

Create java class

Write "HelloWorld" in the 'Name' field and select the check-box for 'public static void main(String[] args)'.

Write class name

Click "Finish" button. Eclipse will generate a java class and open the same in the java editor as shown below.

generated class in java editor

4. Write Java Code

Edit the generated 'HelloWord' java class as per the following code.

File : HelloWorld.java
package com.srccodes.example;

public class HelloWorld {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println("Hello World");
	}

}

               

 

5. Run Your Code

Right click on 'HelloWorld.java' and select from context menu 'Run As' --> 'Java Application'.

Run your code

 

6. Console Output

Your code will print 'Hello World' in the eclipse console.

Console Output

 

Download Source Code

 

References