How should I change Target JRE in Eclipse. I was earlier using jdk1.7, now I want to use JDK 1.6. But while running my java program I am getting Unsupported Class Version Er
You should right-click the project and set the Java Build Path
to use the 1.6 JDK and at the Java Compiler
settings set the compliance level to 1.6.
If you don't have the 1.6 option, you probably didn't add the 1.6JDK to the Installed JRE
s list. To do this go to Window > Preferences > Java > Installed JREs
and add it there.
Sometimes I had troubles with the Eclipse preferences, so if nothing seems to help anymore I try the following.
Switch to the Navigator view, open your project and the .settings folder. Check for the following files and check/update the following settings (depending on the project type there might be different files). I just opened a maven web project.
file org.eclipse.jdt.core.prefs:
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
file org.eclipse.wst.common.project.facet.core.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="jst.java" version="6.0"/>
...
</faceted-project>
file .classpath (in app root, not .settings directory)
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
Basicly you can search for 1.7 and 7.0 in the enclosing project, to check/update the settings.
Go to
Window -> Preferences ->
Now Select and Expand Java
Now Select option Installed JREs
and now you can add new JRE to it.
Use the target JRE with the cross-compilation options when compiling! I am not sure how to achieve that using the Eclipse preferences, but is simple to do when using the Oracle Java SDK & compiling using Ant (Eclipse can run Ant scripts).
If the project has been already started with JDK 1.6, you have to change also the project level settings, so :
Project ---> Properties ---> Java Compiler : set compliance level and Source compatibility to 1.7
Project ---> Properties ---> Java Build Path ---> Libraries ---> and change the JRE system library to 1.7