How to Change Java Version in an Eclipse Project | Baeldung

We ’ rhenium looking for a DevOps engineer with sock, LAMP, and LEMP stack know : Read More

1. Overview

In the Java ecosystem, as the modern releases of JDK are introduced at least once a year, we ‘ll credibly need to switch to a newer version at some point .
In this promptly tutorial, we ‘ll show how to check the available JREs, add a JRE to Eclipse, and change a Java translation in an Eclipse plan, so we ‘ll be quick when that meter comes.

2. Check Whether the JRE Is Available in Eclipse

After being sure that we have installed the version that we want to use, we ‘ll need to ensure that it ‘s available to use in Eclipse .
Let ‘s take a spirit at Window – > Preferences, and within that, Java – > Installed JREs :
window preferences before adding jre extended window 1
If the JRE we want is listed, then we ‘re well to go. But, suppose we need to use JRE 9, 10, or 11. Since we only have JDK 8 installed, we ‘ll have to add it to Eclipse .

3. Adding a JRE to Eclipse

future, from the Window – > Preferences dialogue, let ‘s click the Add… button. From hera, we need to specify the JRE type. We ‘ll choose Standard VM :
add jre standard vm option 1
And last, let ‘s specify the localization of the new JRE ( under the JRE home ) and click coating :
add jre with location 1
As a result, we now have two JREs configured in our IDE :
new jre added 2

4. Change the Java Version of Our Project

now, let ‘s suppose that we were using Java 8 in our project and immediately we want to change it to Java 10 :

project in project tree before changing jdk
first, we ‘ll navigate to the project properties and then to the Java Build Path :
project with java8 before changing jdk 1
and hit the Remove button on the existing JRE :
java build path empty 1
now, we ‘ll use the Add Library button and choose the JRE System Library :
add library window 2
Let’s choose JavaSE-10 from the JDK that we recently installed and click the Finish button :
jre system library window 1
now, as we can see, we ‘ve correctly configured our project ‘s Java Build Path :java build path after change to java 10 1
We need to do one extra step — make sure we’re using the correct Compiler Compliance Level for the Java Compiler :
java compiler after switch 1
In our character it says Java 10, so we ‘re all adept :
project with java 10
In character the Compiler Compliance Level is not the discipline one, we can merely uncheck the Use submission from execution environment option and choose the adjust one .

5. Conclusion

In this quick article, we learned how to add a new JRE into our Eclipse workspace and how to switch to a different Java translation in our current Eclipse stick out.

Java penetrate

Get started with Spring 5 and Spring Boot 2, through the Learn Spring course:

>> CHECK OUT THE COURSE
Generic pedestrian banner

source : https://thefartiste.com
Category : Tech

About admin

I am the owner of the website thefartiste.com, my purpose is to bring all the most useful information to users.

Check Also

articlewriting1

Manage participants in a zoom meeting webinar

Call the people who attend the meet as follows Alternate host host Who scheduled the …

Leave a Reply

Your email address will not be published.