11 Eclipse settings you must know for Java development

Eclipse is one of the most popular IDE for java development. Get to know the eclipse settings is essential. Some of the settings are “hidden” and take time for you to find out. Here I list the basic 10 eclipse settings that will help you cut to the chase.

Top 10 eclipse settings are:

1. Open the Exiting Projects
2. Red sign on Project in Package Explorer
3. Change System Library
4. Run JUnit
5. Import External JARs
6. Turn on Autosave
7. Run with Arguments
8. Increase JVM heap size
9. Find the Command Line to Run the Program
10. Upgrade Eclipse to a Newer Version
11. Add Tomcat Server

1. Open the Exiting Projects

To open the java files in a folder:

Go to the top menu, File -> Open Projects From File Systems…, click the “Directory…” button, navigate to the folder which contains the java files.

eclipse import projects from file system

To open Maven project:

Go to the top menu, File -> Import…, select Maven -> Existing Maven Projects, click Next. In the “Import Maven Projects”, click “Browse…” button,  navigate to the folder that contains pom.xml.

eclipse import maven project

2.  Red sign on Project in Package Explorer

If you see red cross or exclamation mark on the project in the Package Explorer, open “problem” to  find the errors and fix them.

eclipse red sign on project

Go to the top menu, Window -> Show View -> Problems. If “Problems” is not in the right list, select “Others…” and select the Problems.

eclipse select problems view

In the “problem” tab, expand and read the details about the errors.  

eclipse problems tab

3. Change System Library

When you open somebody else’s projects in your eclipse, you may see the java files have the errors to import Java packages. To fix this, you need to change system library for the project.

In the Package Explorer, right click the project -> build path -> configure build path…, click Libraries tab.   Highlight the “JRE System library”, click “Remove” button.

eclipse jre system library

Then click “Add Library…” button, select the “JRE System Library”, click “Next”. Add the installed JDK on your computer.

eclipse add jre system library

Then click “Apply and Close”. The errors should be gone.

If it is a maven project, the jdk might be defined in pom.xml, as shown below. You should change the version accordingly.  


4. Run JUnit

If you wand to add JUnit test cases in the project, you have to add JUnit Library first.

Right click the project -> build path -> configure build path…, select “Libraries” tab. Click “Add Library…” button. In “Add Library” pop up, select “Junit”, click “Next”. In the next window, select “Junit 4”  or “Junit 5” available in eclipse. Click “Finish”.  

eclipse add junit

To add JUnit test case, right click project, New -> JUnit Test Case.

eclipse add junit test

To run the test cases, right click the project , Run as ->JUnit Test.

run junit test

5. Import External JARs

Some projects require external jar files, such as gson, Java fx, derby embedded db etc. First, you need to download the jar files online. Then right click the project -> build path -> configure build path…, select “Libraries” tab.  Click “Add External JARs…” button at right, navigate to the folder where the jar files are  located. Select the jar file, click “OK” button.

add external jars

6. Turn on Autosave in eclipse settings

When you make any changes in the code, you can run it without click saving button. This is autosave. You can turn on autosave in the preferences.

Go to top menu, Window -> Preferences -> Run/Debug -> Launching. In “Save required dirty editors before launching”, check the radio button “Always”.

eclipse autosave

7. Run with Arguments

If you want to pass the values to the program args (the same as how you run from command line), you can define the arguments in eclipse:

Right click the project, select Run As -> Run configurations…

run configurations

select “Arguments” tab, enter values in one line, separated with space.

eclipse add arguments

8. Increase JVM heap size

If your program read in big file and run out of memory, you need increase the heap size.

Right click the project, select Run As -> Run configurations. Click “Arguments” tab. In VM Argument area, Increase heap size like this “-Xms4096m -Xmx4096m”

increase heap size

9. Find the Command Line to Run the Program

Sometime after you compile the code and run successfully in eclipse, you want run from Java programs (eg, multi-threading program) from command lines. If you run into errors such as Java class not found, you can get the command line arguments from eclipse.   

Go to the top menu, Window -> Show View -> Others…, select “Debug” in window “Show View” .  The Debug tab will appear next to Console.

debug tab

Right click the last line in Debug -> properties

eclipse debug properties

The “Properties for” window will show the Path and Command Line. You can copy this line and paste to your cmd window (Windows) or terminal (Mac) to run the java command.

10. Upgrade Eclipse to a Newer Version

First, find the eclipse version you want to upgrade to. They are at https://en.wikipedia.org/wiki/Eclipse_(software).  Next you can construct your download link, for example https://download.eclipse.org/releases/2020-09/.

In Eclipse, go to the top menu, Window > Preferences -> Install/Update > Available Software Sites , click “Add…” button.
Name : update eclipse latest
Location: https://download.eclipse.org/releases/2020-09/
click OK.

eclipse update new version link

Go to the top menu again, Help > Check for Updates, check “Select all”, click “Next”.

eclipse available updates

After it is complete, restart Eclipse.  When eclipse restart, skip the “workspace not compatible” message, click  “Continue” to finish.

After you upgrade, you can adjust some eclipse settings. For example, you can add new java jdk version. Go to the top menu, Window ->  Preferences -> java -> Installed JREs. Click “Add… ” to add JDK you have downloaded on your computer.

eclipse installed jres

11.  Add Tomcat Server

When you build web applications or web services, you need to install  web application server for test purpose. Apache Tomcat is one solution. You can download Apache tomcat zip file at http://tomcat.apache.org/.

Unzip the folder to the local drive. In Eclipse, Go to the top menu,  File -> New -> others…, select “Server”, click “Next”.  Select the version you downloaded and click “Finish”.

eclipse add tomcat server

To run the web project, right click the project, Run as -> run on server.

eclipse run on server

What is Software Engineering about
Life of Java Developer

Comments are closed