Eclipse IDE is one of the most powerful integrated development environments (IDEs) ever built. This well-designed, robust, and feature-loaded IDE is in use in most of the current IT environments. This article provides an overview of how to get started using Eclipse IDE, from installation and to executing a program and using shortcuts.
Java is an important prerequisite for using Eclipse IDE. Therefore, the first step is to install Java onto your local Windows operating system. The procedure you should follow to install Java includes the following steps:
Create your Oracle account
Oracle has commercialized the Java Development Kit (JDK), making it available in two different versions: Oracle JDK and Open JDK.
Oracle JDK is free for beginners, so it might be your best option when you’re just starting out. Once you try to download a specific version of JDK, the Oracle site asks you for user credentials. If you don’t already have those, feel free to create one as you won’t be charged.
Download the specific version of JDK
Once you select the Windows version to download, you will then be asked to accept the terms and conditions, as shown below.
After you check the box to accept the terms and conditions, you're free to continue downloading the zip file.
Unzip the downloaded JDK file
The JDK zip file will be available in your download folder. Unzip it and copy the location of the bin folder as shown below.
Your file will look like this after you extract it:
Open the folder and enter it into the bin file and copy the bin file location, as shown below.
Now that you have copied the bin file location, you are ready to set the Java environment in your Windows Operating System.
Java environment setup can be done through the Windows advanced settings. Follow the steps, as shown below.
First, go to your desktop, right-click on the This PC icon, and select properties as shown below.
After selecting properties, you will enter the system information window that will describe your computer hardware specifications and operating system details. On the left-hand top corner, you will find a set of options, out of which you need to select advanced system settings.
After selecting the advanced system settings option, you will enter into the next window where you need to choose Environment Variables, as shown below.
Once you enter the Environment Variables, you will set the JAVA_HOME and JAVA_PATH variables in the next window.
You can see the User variables in the top dialogue box. Select the new option, and you will get another dialogue box where you can set JAVA_HOME and the address of the JDK bin folder, as shown below.
Select OK, and the JAVA_HOME will be set.
In the next stage, we will set the JAVA_PATH. For that, we need to select and edit the Path from the Environment Variables window in the System Variables dialogue box, as shown below.
After you select the edit option, you will need to choose "new" and add a new JAVA_PATH variable, as shown below.
Now, go ahead and add the path to the row and select OK, as shown below.
Then, you can close the Environment Variables window by selecting OK, and both your JAVA_HOME and JAVA_PATH should be successfully set.
Verify Java installation through command prompt
Press the keys “Windows+R.” This step will open a Run window. Then, type CMD and select Run, as shown below.
Select OK, and you will see the command prompt window. Here, type in java -version and press the enter key. This step will show you the current version of Java installed in your local Windows OS as shown below.
Now, we have successfully installed Java into our local Windows system.
Versions of Eclipse IDE
Eclipse IDE is available in a few different versions. I'll mention some of the more popular versions of Eclipse IDE:
- Eclipse Luna (Released on 6/25/2014)
- Eclipse Mars (Released on 6/24/2015)
- Eclipse Neon (Released on 6/22/2016)
- Eclipse Oxygen (Released on 6/28/2017)
- Eclipse Photon (Released on 6/27/2018)
The current version of Eclipse is Eclipse Photon 4.17.
Install Eclipse IDE
Now that we have installed Java and have a thorough briefing on the various Eclipse versions, let’s move on and install Eclipse IDE into our local Windows operating system.
We can install Eclipse by following the steps below.
Step 1: Download Eclipse.
To download Eclipse, you need to search for “Eclipse” and click on the link which reads "Eclipse Download for Java EE."
On the next page, you can see a link to the installer file on the right side of the screen. It looks something like this.
Click on the Download button. It will take you to the next page where you can download the installer by pressing the Download button again.
After successfully downloading the Eclipse installer, you’ll want to run the installer.
When you start the installer, you will see this image:
After the installer starts, it will ask you for the type of Eclipse IDE you require. Eclipse can be used for multiple applications, including web development, PHP development, C/C++ development. For our purposes, we want to download Eclipse IDE for Enterprise Java Developers.
Click on the Eclipse IDE for Enterprise Java Developers button to download the required IDE.
After selecting the required IDE type, you can see the following screen where you can set up your application installation location. I have chosen the C Drive.
After that, just press install and your software will start installing into your system.
After you finish the installation, the installer window will ask you if it can launch now.
Just press the Launch button if you wish to start with IDE right away. You will now see the Eclipse IDE getting booted up.
Next, you need to set up a separate folder for your workspace. Eclipse will select a default workspace for you. Either you can continue with the default or create your workspace location and then click on the launch button.
Now you have the Eclipse IDE successfully launched into your local Windows OS.
Next, we will take a tour of Eclipse IDE so that we can better understand its usage and functionality.
Eclipse IDE Tour
When you start to use any IDE, you need to learn about its menu and editor perspectives.
Similar to any other IDE, Eclipse has a menu bar that incorporates the following:
As shown below:
Now let us understand the functionality of each of these
The “File” menu is like your console that has the most important options that allow you to create a new project, import/export an existing project, switch between workspaces, restart Eclipse IDE, and more.
As you probably already know, the “Edit” bar allows users to edit code as well as copy and paste.
The “Source” tab has some specific operations related to the code editor. Hence, it is available when the code editor is active.
The “Refactor” menu helps programmers with all of the possible changes that can go into the Java Code Block.
The “Navigate” option allows users to quickly navigate throughout the available resources.
The “Search” tab performs the task of searching for a specific file, folder, or workspace.
The “Project” menu helps with the requirements needed by the developer when building a brand new project.
The “Run” menu incorporates the many crucial functionalities related to the code. You can debug, run, and fix the code by setting breakpoints through run.
The “Window” option helps users open and close different perspectives of the code editor.
“Help” provides the users with all sorts of information related to the Editor and provides access to the Eclipse Marketplace so that we can install plugins when required.
A “View” provides an overview of the entire data in the project in graphical representation, such as the project folder, the package folder, the class file, etc.
The view can be opened by navigating to the window menu and then to "show view" as described in the image.
Locate and Activate a View
To locate and activate a view, you can move to the window button, then to show, and lastly, press the other button. This procedure provides the user with locating and activating functionalities.
A “Perspective” is a collection of the code editor, views, and console. In Java, you can open multiple perspectives, but you will be confined to using just one perspective at one time. When you download Eclipse Enterprise Edition for Java Developers, the Java Perspective will load as default.
The Perspective icon looks like this:
When you click on the Perspective icon, it looks like this:
Moving ahead, we will learn about WorkSpaces.
When you’re working in Eclipse, the left tray is your workspace window. The project name is at the top, followed by the package, and finally (at the bottom) we have the class.
Now that we’ve had a brief tour of the Eclipse IDE, we will now move on to creating a sample project in Eclipse.
How to Begin with a New Project
Creating a Project
Creating a Java project is simple. You can create a new project by following the procedure below.
Go to the File menu, Select New, navigate to Java Project, and click it.
Then you can see a new dialog box on the screen where you can name your project and add some credentials to it.
Moving ahead, we will now learn how to create a new package.
Creating a Package
Similar to creating a new project, creating a new package is simple as well. You can create a new package by going through the procedure below.
Go to the newly created project, right-click on it and navigate to New and select New Package in the dropbox, as shown below.
Next, we’ll create a new class.
Creating a class
To create a new class, you will need to navigate to the newly created package and right-click on it. By doing so, you will see a dropbox where you can select New and then browse to Class and click on it. This process should create a new class.
Next, we will learn how to create a new interface.
Creating an interface
To create a new interface, you will need to right-click on Package and select New. In the next dropbox, select the Interface option.
Creating an enum
To create a new enum, you will need to right-click on Package and select New from the dropbox. In the next dropbox, select the Enum option.
Creating an annotation
To create a new annotation, you need to right-click on Package and select New from the dropbox. In the next dropbox, select the Annotation option.
Setting up a build-path
We might need extended support to design and deploy some advanced projects using Eclipse. Maven Build Tool, for example, requires XML files as a dependency. So, we use build-path to make sure Eclipse identifies the embedded dependencies.
We can include the build-path by entering it into project properties. You can open the properties either by pressing Alt + Enter or right-clicking on the Java Project and navigating to Properties.
Once you enter properties, navigate to Java Build Path and add your JARs if available in Eclipse or add the downloaded JARs from your local file system.
Once you have set up the build-path, the next thing you need to do is to create an XML file.
Creating an XML file
Including JAR files
JARs are necessary when you are working with a project that requires few external dependencies. You can add external or internal JARs by navigating to File and selecting the Export option. Clicking on “Export” will open a new window, wherein you can type and search for JAR, and you will get a few inbuilt JAR files.
Enter your required internal/external JAR, and then you can click on Next and finish.
Executing a Program
Debugging is a very crucial step in developing any software, but it’s also one of the most tedious tasks. Fortunately, Eclipse has a built-in debugging capability that can help you debug your code much more easily.
You can do the debugging process by following the steps as shown below.
Select the Debug option, and the Debug Configuration dialog box will open on your screen, allowing you to set and execute your debugging setup.
Provide your configurations and select Debug to execute the debugging procedure.
Setting up breakpoints
Sometimes you may foresee the requirement of a particular code segment and type it in, even though you might not need it right away. Or, a specific existing code segment may be causing some issues to your debugging configuration.
In such situations, you can use breakpoints in your code to tell the compiler to avoid simply compiling that code segment. Setting up breakpoints can be done by either double-clicking on the line number tray or right-clicking on the line to select the breakpoint option in the dropdown menu.
Now, we will learn Quickfix.
As the name suggests, a Quickfix is a built-in feature from Eclipse that identifies minor mistakes in code and instantaneously provides alternate solutions that can fix the code.
When you make specific changes, Eclipse sometimes fails to identify them. Your best option is to restart the whole IDE to implement the changes (while prompting Eclipse to identify it).
You can restart the project by selecting the File menu and navigating to Restart.
When you have finished debugging the code and fixing all of the errors, the final stage will be to run your project. Executing can be done by right-clicking on the project, selecting a run option, or simply selecting the Play icon from the toolbar.
Next, we will review the Eclipse Marketplace.
Eclipse IDE Marketplace
Eclipse Marketplace is a personalized website hosted and operated by the Eclipse Foundation. Here, you can download all of the tools, JARs, plugins, and bundles you may need.
Eclipse Marketplace can be accessed by clicking on Help from the menu bar and navigating to the Eclipse Marketplace option.
Finally, we will cover the various shortcuts in the Eclipse IDE.
Eclipse IDE Shortcuts
Shortcuts can be quite handy regardless of how small or significant a project you’re working on. Some of the most important and most frequently used shortcuts include:
- Control + Shift + O to rearrange imports in the proper order
- Control + 1 for the Quickfix window
- Control + Shift + R to fetch any resource files, such as the XML dependency file
- Control + Shift + Up arrow key to navigate between different members in the project
- Control + K for finding the next class
- Control + Shift + K for finding the previous class
- Alt + Right to go back while editing the code
- Alt + Left to go forward while editing the code
- Control + / to comment in the code
- Control + Shift + W to close all code files
- Control + F for find and replace
- Control + D for deleting a particular line
- Control + Q to navigate to the last edited code segment
- Control + E to navigate to the other editor
- Control + Shift + F for auto indentation
The preceding information should give you a concise overview of Eclipse IDE’s essential prerequisites, it’s different versions, and all of the necessary procedures to be followed to install Eclipse in the Windows OS. If you’re interested in learning more about Java and getting certified, thus expanding your career options, check out our online Java Certification Training Course, curated by the most experienced real-time industry experts.
Got a question for us? Please mention it in the comment section and we'll have our experts answer it for you.