In this Post, We will see how to do Eclipse Configuration in Java, how to write first Java program, how to run it and various shortcut Keys which is useful while writing Java programming.
Table of Contents
1.You can start eclipse by double clicking of “eclipse.exe” (where you save eclipse setup folder)
(No need to install eclipse)
Download Eclipse from Here. Download Page
2. When eclipse start up for the first time it will open Workspace launcher window for the location of the workspace folder. All your data will be stored in the workspace local folder. You can accept the default or choose a new location in your system.
3. If you select “Use this as the default and do not ask again”, this dialog box will not come up again.
4. After closing welcome tab will display.
5. The visible parts of an eclipse window are below.
Create New Project in Eclipse:
- Click on file menu and choosing New > Java Project
- If java project option is not available then go to other > Java Project
3. Enter the Project Name
4. Select the Java Runtime Environment (JRE) or leave it at the default.
5. Select the Project layout which determines whether there would be a separate folder for the source code and class file
6. The recommended option is to create separate folders for sources and class file.
7. You can click on the finish button to create the project
8. The package explorer shows the newly created Java project
9. By right click on the src folder in package explorer New > Package
10. After that New Java package window open to create java package.
- Enter the package name.
- Click on finish button.
- The package explorer will show the newly created package under the source folder.
- After creating package e.g. firstPackage
- Right click on that package Select > New > Class
- Click on finish to create the class.
How To Run Java Program in Eclipse:
In left hand side package explorer view:
- Right click on the class which you have created
- Select Run As > Java Application
Various Shortcut Keys in Eclipse:
|1||Any type of relevant suggestion||Ctrl + Space|
|2||Main Method||Type “Main” and Ctrl + Space. Select main from suggestion|
|3||Printing Statement||Type “syso” and Ctrl + Space.|
|4||Delete Line||Ctrl + D|
|5||Duplicate Line||Ctrl + Alt + Down Arrow|
|6||Comment||Ctrl + Shift + Forward Slash|
|7||Save All File||Ctrl + Shift + S|
|8||Close File||Ctrl + W|
How to Add Extra Plugin in Eclipse:
Go to Help > Eclipse Market Place
Below dialog box will be open. Type plugin name and hit enter.
How To Add External libraries in our project in eclipse:
If you are going to use API which is except Java and J2ee then we need to add external libraries in our project.
For Java and J2ee it automatically install by default when we install JDK (Java Development Kit).
E.g. If I want to use Selenium then we need to add external jar file of Selenium into eclipse.
Right click on project > Build path > Configure Build Path
After Select jar files from your local PC, Click on Apply and Close button.
Eclipse Configuration Settings:
Editing the Launch Configuration Parameters-
In order to run an application, if we need to explicitly set the working directory, we need to edit the launch configuration parameters for the application.
Follow below steps to edit launch configuration parameters-
Right click on project > Click on Properties
Click on Run/Debug Setting > Click on New button. After click on New button we can see below screen.
Select ‘Java Application’ and Click on OK. Then below screen will be open.
You can edit here any section as per your choice.
In this post, we have covered “Eclipse Configuration” For Java, how to write first Java program, how to run it and various shortcut Keys which use is useful while writing Java programming.
I am sure this content added some additional value in your skills and also helpful to configure eclipse.
Final word, Bookmark this post “Eclipse Configuration” for future reference.
If you have other questions or feedback, the comment section is yours. Don’t forget to leave a comment below!