且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Eclipse中使用jdk 1.6和jdk 1.7来为不同的项目

更新时间:2022-10-14 23:13:58

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




  • 要设置整体工作区属性,请单击窗口> 首选项,然后导航到 Java >

  • 要设置项目属性,请右键单击项目,然后选择属性。导航到Java编译器并选中启用项目特定设置



您可以从已安装的JRE中进行选择为任一设置。要告诉Eclipse有关新安装的JRE,您可以打开工作区首选项并导航到 Java > 安装的JRE ,然后点击添加按钮。


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?

The following is the "problem" view

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

You can set overall workspace properties to use one version of Java and set individual project properties to use another.

  • To set overall workspace properties, click on Window > Preferences, then navigate to Java > Compiler.
  • To set project properties, right-click on the project and select Properties. Navigate to Java Compiler and check "Enable project specific settings"

You can choose from among the installed JREs for either setting. To tell Eclipse about a newly installed JRE, you can open the workspace preferences and navigate to Java > Installed JREs and then click the "Add" button.