4

I am using Eclipse with JDK 1.7. My previous projects are developed in java 7 and JDK 1.7. Now, I want to build a new project under JDK 1.6 in Eclipse. Is it possible to do that so that some projects are based on JDK 1.7 and some others are based on JDK 1.6 without conflicts?

If this can be done, please let me know how to do it step by step.

Update: My default JDK is 1.7. I created a new project that is based on jdk1.7 by default. And then I go to the property of this project, and then java compiler, then change the compliance settings as the image shows below. But there is some error occurred. What could be the reason causes this error?

enter image description here

enter image description here

The following is the "problem" view

enter image description here

After some research, I have solved this problem. please see the reference about how to fix the facet version.

4

3 回答 3

3

您可以设置整体工作区属性以使用一个 Java 版本,并将单个项目属性设置为使用另一个版本。

  • 要设置整体工作区属性,请单击Window > Preferences,然后导航到Java > Compiler
  • 要设置项目属性,请右键单击项目并选择Properties。导航到Java 编译器并选中“启用项目特定设置”

您可以从已安装的 JRE 中选择任一设置。要告诉 Eclipse 新安装的 JRE,您可以打开工作区首选项并导航到Java > Installed JREs,然后单击“添加”按钮。

于 2013-07-29T16:00:57.697 回答
0

这可以为 Eclipse 运行配置完成。您可以定义多个这样的配置,每个配置都将在您的一个项目中引用一个“主类”。

  1. Window -> Preferences -> Java -> Installed JREs中为每个 JRE/JDK 定义一个位置。

  2. 对于给定的 Eclipse 项目:

    • 右键单击项目,选择Properties -> Java Compiler,覆盖并设置编译级别设置。

    • 检查Use compliance from ...,访问Java Build Path并确保您有一个符合所需合规级别的 JRE 库集。

  3. 对于给定的 Eclipse 运行配置:运行 -> 运行配置... -> Java Application,选择旧配置或创建新配置,选择JRE选项卡并指定运行时 JRE

于 2013-07-29T15:59:32.597 回答
0

您可以在 Project properties( alt+enter)-> Installed JREs 下更改项目使用的 JDK。调试配置也是您的朋友。您可以设置在 Eclipse 中启动/运行应用程序/程序时要使用的 JDK。

于 2013-07-29T16:00:56.437 回答