In this tutorial, we will learn to create the Hello World application using Eclipse IDE. To understand the following material you should be familiar with using Eclipse for instructions on Eclipse Click Here.
Creating the Project
To create our project select File >> New >> Java Project from the menu. If you can’t find “Java Project” as an option then click “Other” as shown below.
Select Java Project from the next window and click Next. Provide a project name as shown below.
Click Finish. Eclipse will ask you to change the perspective to Java Perspective. Click Yes. As you can see a new Java project will appear in the Package Explorer view in the Java Perspective.
Creating a Package
Now we will create a package for our Java project. Packages are used to avoid naming conflicts, to control access (Access Modifier) and to bundle groups of related types.
To create your package select the src folder in your Java project (JBTProject), Do this by right-clicking on it and select New >> Package.
Enter the package name in the dialog box and click Finish.
Steps to Create the Java Class
Once your package is created we can create the Java class inside the package. Right-click on the package in which the Java Class is to be created and select New >> Class.
Provide the Class name in the dialog box and click Finish. Other options are available to choose from. Select Other Option to create your main Methods.
Once Class has created the structure of the project would be as shown below.
Compile & Run Java application
After creating the Java application the next step would be to compile and run the code.
Compile the code
To compile the code use the keyboard shortcut “CTRL+B”. It will build the Java applications. If you want to build a single application then click the application and select Project >> Build Project from the menu.
Run the code
To run the code you can either use the keyboard shortcut “ALT+SHIFT+X” and J.
Or you can click the file and select Run >> Run As >> Java Application from the Menu.
Once you click Run the Hello World application will be executed and your output will be displayed in the console view.
We have now learned to create the Hello World application in Eclipse. In the next article, we will discuss some other features provided by Eclipse which makes coding easier.<< Constructors in Java Order of execution >>