在Eclipse中使用jdk 1.6和jdk 1.7来为不同的项目 [英] Using both jdk 1.6 and jdk 1.7 for different projects in Eclipse

查看:539
本文介绍了在Eclipse中使用jdk 1.6和jdk 1.7来为不同的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Eclipse与JDK 1.7。我以前的项目是在java 7和JDK 1.7中开发的。
现在,我想在Eclipse中在JDK 1.6下构建一个新项目。有可能这样做,以便一些项目基于JDK 1.7,而其他项目基于JDK 1.6而没有冲突?



如果可以完成,请让我知道如何一步一步。



更新:
我的默认JDK是1.7。我创建了一个基于jdk1.7的新项目。然后我去这个项目的属性,然后java编译器,然后更改合规设置,如下图所示。但是有一些错误发生。原因是什么原因导致此错误?







以下是问题视图





经过一番研究,我已经解决了这个问题。请参阅如何修复方面的参考版本。

解决方案

您可以将整体工作区属性设置为使用一个版本的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.

这篇关于在Eclipse中使用jdk 1.6和jdk 1.7来为不同的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆