Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change JDK version for an Eclipse project

Tags:

java

eclipse

jar

I need to write a project that's only compatible with Java 1.5. I have Java 1.6 installed. Is there some form of backwards compatibility to get Eclipse to compile with 1.5?

Do I have to install Java 1.5 to get it to show here? Or maybe there is another way?

Enter image description here.

like image 756
David Avatar asked Sep 25 '12 17:09

David


People also ask

How do I switch to Java 11 in Eclipse?

A Java 11 JRE is recognized by Eclipse for launching. It can be added from the Window > Preferences > Java > Installed JREs > Add... page. It can also be added from the Package Explorer using the project's context menu.


2 Answers

Click on the Add Library button. It brings your screen to point to the Java location.

Select "Directory", button right besides JRE home and point to the installed folder location.

Even though you want to just 1.5 compiler project, you can achieve it by changing compiler settings in Eclipse instead of removing 1.6 JRE and add 1.5 JRE.

GOTO -->JAVA--Compiler---> and change compiler level to `1.5` instead of `1.6` 

As davidfmatheson suggested,

Just be careful, especially if you're setting this up for a team of people to work on. If anyone uses anything that is new or changed in 1.6, it will compile, but not run in an environment with JRE 1.5.

like image 135
kosa Avatar answered Oct 22 '22 13:10

kosa


Click on the Window tab in Eclipse, go to Preferences and when that window comes up, go to JavaInstalled JREsExecution Environment and choose JavaSE-1.5. You then have to go to Compiler and set the Compiler compliance level.

Changing JRE

Enter image description here

like image 33
Ronald91 Avatar answered Oct 22 '22 15:10

Ronald91