Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Java Version From Within Eclipse

I wrote a project in eclipse with an older version of java. Now on a different computer but running the same codes I'm getting a whole lot of red.

This is due to Version incompatibility. I've had my professor change the Java version from within the console window before. The code compiled just fine after he did so. I'm sure its the same case with this code.

After looking at other tutorials and google links I could only find command line approaches and @override methods. To be honest I still don't understand these.

What is the best way to change the version of a code originally written in an older code inside the eclipse console? thanks!

like image 287
user1320668 Avatar asked May 03 '12 02:05

user1320668


People also ask

Can we change Java version in Eclipse?

If you want to change any jdk version of A specific project than you have to click ---> Project --> JRE System Library --> Properties ---> Inside Classpath Container (JRE System Library) change the Execution Environment to which ever version you want e.g. 1.7 or 1.8.

How do I change the default version of Java in Eclipse?

Configure the default JRE Download and install a Java JDK v1. 7 or greater. Set it as the default in Eclipse by selecting Preferences -> Java -> Installed JREs. Add the installed JDK and select the checkbox, making it the default.

How do I update Java 11 in Eclipse?

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. An option to set compiler compliance to 11 on a Java project is also provided.


2 Answers

In eclipse go to Window -> Preferences -> Java -> Compiler, there you can change the java versions. Hope it helps.

like image 117
raddykrish Avatar answered Sep 27 '22 19:09

raddykrish


Ideally if we want to have two different versions of Java [say 1.6 and 1.7], then we should have two workspace defined accordingly to avoid any mixup. We can also change the Project Facets if our projects has facets that is.

In Eclipse Follow steps given below: 1) Windows -> Preferences -> Java -> Compiler and as per the image set the compliance compiler level as per your requirements. Compiler Compliance Level Not Project Specific

2) Windows -> Preferences -> Java -> Installed JRE's and check if your required jre/jdk is available or not as given in image below: Installed JRE's Not Project Specific

3) Right Click on Your Project and go to Java Build Path and check if your required Library is available or not as per image given below: Java Build Path Project Specific

4) Now you can edit the JRE System Library or add one by clicking on button's available on last image's right side, then a pop up as given below will open up. Here, you can change the execution environment [default values also can be set] Edit/Add Library

like image 37
akshaymani Avatar answered Sep 27 '22 19:09

akshaymani