Create a new Java project and program in Eclipse

In previous post we saw how to download eclipse and create a new workspace. Now let us see how to create a new Java project, program and run the program in Eclipse.

Steps to create and run Java program :

Step 1 : After eclipse has opened, a welcome screen will appear. You can explore the features if you want through welcome screen. After that close the welcome tab.

Step 2 : Go to ‘File’ on the menu bar and select ‘New’. Now from the opened options select ‘Other…’.

Step 3 : A new dialog box will open select ‘Java Project’ from the list of options.

Step 4 : A new popup window will appear. Now fill the appropriate Java project name and click ‘Next’ button.

Step 5 : In the next window click on ‘Finish’ button.

Step 6 : A new dialog box will appear asking if you want to open Java perspective. Click on ‘Open Perspective’ button.

Step 7 : This will create a new Java project which can be viewed in the left window (Package Explorer).

Step 8 : Now to create a java program, right click on the project and select ‘New’. Next click on the ‘Class’ option.

Step 9 : A new popup window will open. In the window, give a name to your class. Now tick the box under ‘Which method stubs would you like to create?‘ to create ‘main‘ function. Now click on ‘Finish’ button to create the program.

Step 10 : A new program will be created with the name given by you. Before executing the program, write the below code in the coding window. Replace ‘HelloWorld’ with your own class name.

public class HelloWorld {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		System.out.println("Hello world program is running");
	}
}

Step 11 : Now click the run button in the toolbar to execute the program.

Step 12 : You will be able to see the output in the ‘Console’ window at the bottom of eclipse.

Congrats!! You have successfully created Java program and run the program in Eclipse.

Let us see how to Format code in Eclipse.

Leave a Comment