Rohit Elayathu
Rohit Elayathu

Reputation: 639

Target JRE in Eclipse

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 Error. Is there some setting that I need to do before using jdk1.6. How should i make sure that my eclipse compiles and runs only in jdk1.6.

Upvotes: 5

Views: 22152

Answers (6)

Andrew Thompson
Andrew Thompson

Reputation: 168845

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).

Upvotes: 1

aleroot
aleroot

Reputation: 72696

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

enter image description here

Upvotes: 8

proko
proko

Reputation: 1210

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.

Upvotes: 1

Ved
Ved

Reputation: 8777

  1. Go to : Windows -> preferences -> Java -> compilers -> JDK compliance
  2. Change installed JDK version accordingly.

Upvotes: 1

Matyas
Matyas

Reputation: 13712

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 JREs list. To do this go to Window > Preferences > Java > Installed JREs and add it there.

Upvotes: 0

gprathour
gprathour

Reputation: 15333

Go to

Window -> Preferences ->

Now Select and Expand Java

Now Select option Installed JREs

and now you can add new JRE to it.

Upvotes: 0

Related Questions