How to Change Java Version in Eclipse
- Download and Add a New Version of JRE in Eclipse
- Change Java Version for a New Project in Eclipse
- Change Java Version for a Current Project 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.
To add a new JRE, users need to click on the Add
button in the Preferences
dialog box.
Users will see another dialog box opened on the screen. Select Standard VM
from that dialog box.
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.
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.
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.
Now, in the sidebar of Eclipse, users can see that a new project has been added with the particular version of JRE.
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.
Choose the JRE System Library
from the Add Library
dialog box and click on the Next
button.
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.
Users can see that a new JRE has been added to the current project.
Furthermore, users can see in the sidebar of Eclipse that the JRE version for the current project has been changed.
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.