How to Change Java Version in Eclipse

Shubham Vora Feb 02, 2024
  1. Download and Add a New Version of JRE in Eclipse
  2. Change Java Version for a New Project in Eclipse
  3. Change Java Version for a Current Project in Eclipse
How to Change Java Version in Eclipse

It may be needed that users have to degrade or upgrade the Java version while working on a particular project. In such a case, Eclipse IDE allows us to change the JDK version for a particular project.

This article explains the step-by-step guide to changing the Java version in the Eclipse IDE.

Download and Add a New Version of JRE in Eclipse

Before we learn to change the Java version for the current project, we have to ensure that we have downloaded and added that JDK version in Eclipse. Otherwise, users can follow the below steps.

Open the Eclipse IDE, and go to Window > Preferences from the Menu bar; it will open up a dialog box. Go to Java > Installed JRES in the dialog box.

As shown in the image below, all JREs are added to the Eclipse. If a user finds whatever version of JRE is needed here, users can skip the below steps and proceed towards changing the Java version for any particular project.

eclipse change java version - 1

To add a new JRE, users need to click on the Add button in the Preferences dialog box.

eclipse change java version - 2

Users will see another dialog box opened on the screen. Select Standard VM from that dialog box.

eclipse change java version - 3

Now, users will see a dialog box opened on the screen to add a new JRE. Users must find the location of the JRE installed and copy that path inside the JRE home text field.

Users can insert any name inside the JRE name text field. After that, users have to click on the Finish button.

eclipse change java version - 4

Users can see another new JRE added to the Eclipse in the image below. Click on the Apply and Close button at the bottom of the dialog box.

eclipse change java version - 5

We have successfully added the new JRE to Eclipse.

Change Java Version for a New Project in Eclipse

Users should follow the below steps to use the custom Java version for the new project.

To create a new project, go to File > New > Java Project. It will open a dialog box.

Fill in the name for the project and choose the JRE inside the JRE section.

eclipse change java version - 6

Now, in the sidebar of Eclipse, users can see that a new project has been added with the particular version of JRE.

eclipse change java version - 7

Change Java Version for a Current Project in Eclipse

If users have already created the project and want to change the JRE version for a particular project, they should follow the below steps.

In the sidebar of Eclipse, right-click on the project name and click on Properties to go to the project properties dialog box. Next, in the dialog box, move to the Java Build Path from the sidebar and Libraries from the top bar.

Next, select the JRE System Library [jdk - version] and click on the Remove button to remove the Java version from the current project.

After that, users should click on the Add Library button from the right sidebar in the dialog box. If the button is disabled, select Modulepath, and it will be enabled.

eclipse change java version - 8

Choose the JRE System Library from the Add Library dialog box and click on the Next button.

eclipse change java version - 9

In the System Library section, choose the Alternate JRE radio button and change the JRE version from the dropdown menu. After that, users have to click on the Finish button.

eclipse change java version - 10

Users can see that a new JRE has been added to the current project.

eclipse change java version - 11

Furthermore, users can see in the sidebar of Eclipse that the JRE version for the current project has been changed.

eclipse change java version - 12

We have learned to change the Java version for the current or new project in Eclipse. All users need to do is download and install JRE, which they want to use with the project, and add it to Eclipse.

After that, users can customize the JRE version for Java projects.

Author: Shubham Vora
Shubham Vora avatar Shubham Vora avatar

Shubham is a software developer interested in learning and writing about various technologies. He loves to help people by sharing vast knowledge about modern technologies via different platforms such as the DelftStack.com website.

LinkedIn GitHub

Related Article - Java Eclipse