Target JRE in Eclipse

后端 未结 6 774
独厮守ぢ
独厮守ぢ 2020-12-18 12:15

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

相关标签:
6条回答
  • 2020-12-18 12:50

    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.

    0 讨论(0)
  • 2020-12-18 12:54

    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.

    0 讨论(0)
  • 2020-12-18 12:54

    Go to

    Window -> Preferences ->

    Now Select and Expand Java

    Now Select option Installed JREs

    and now you can add new JRE to it.

    0 讨论(0)
  • 2020-12-18 13:03

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

    0 讨论(0)
  • 2020-12-18 13:09
    1. Go to : Windows -> preferences -> Java -> compilers -> JDK compliance
    2. Change installed JDK version accordingly.
    0 讨论(0)
  • 2020-12-18 13:12

    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

    0 讨论(0)
提交回复
热议问题