Java Eclipse 将编译器合规性更新为 1.7

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18463067/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 01:50:40  来源:igfitidea点击:

Eclipse Updating the compiler compliance to 1.7

javaeclipsejava-7rtc

提问by Pectus Excavatum

I am having some trouble updating the compiler compliance of my eclipse workspace (I am actually using RTC, but it is essentially eclipse). Currently, it uses a jdk of 1.6 so I can change the JDK compliance to a limit of 1.6.

我在更新 eclipse 工作区的编译器合规性时遇到了一些麻烦(我实际上使用的是 RTC,但它本质上是 eclipse)。目前,它使用 1.6 的 jdk,因此我可以将 JDK 合规性更改为 1.6 的限制。

However, I am using jdk 1.7 for my project -I have added it as a JRE -

但是,我在我的项目中使用 jdk 1.7 - 我已将其添加为 JRE -

preferences --> Java --> Installed JRE --> added jre with the jdk 1.7 directory.

However, even though I use this as the default JRE it does not allow me to change the compiler compliance level to 1.7.

但是,即使我将其用作默认 JRE,它也不允许我将编译器合规性级别更改为 1.7。

I am guessing that there is something I am missing.

我猜我错过了一些东西。

Any help would be greatly appreciated

任何帮助将不胜感激

回答by Narendra Pathai

The Compiler compliance level is Version Dependentin eclipse. If you are using Eclipse 3.7 or lower then you won't get 1.7 compliance. Use Eclipse JUNO or higher.

编译器合规性级别在 eclipse 中是依赖版本的。如果您使用的是 Eclipse 3.7 或更低版本,那么您将无法获得 1.7 的合规性。使用 Eclipse JUNO 或更高版本。

For more on JDT Core 7and its release related information

有关JDT Core 7及其发布相关信息的更多信息

UPDATE:

更新:

Even eclipse 3.7.1version supports Java 7 features and compliance level.

甚至eclipse 3.7.1版本也支持 Java 7 特性和合规级别。

回答by swati yedle

If you are using eclipse 3.7 then you add 1.7 into compliance level by following way:-

如果您使用的是 Eclipse 3.7,那么您可以通过以下方式将 1.7 添加到合规级别:-

  • right click on project
  • click on Build path->Configure Build Path->project Facets
  • there you can see one link 'convert to faceted form'. click on it
  • mark java and select verion 1.7 from dropdown which is present in front of java tab
  • click on apply and click ok
  • now you can see that 1.7 version is appeared in compliance level
  • 右键单击项目
  • 点击 Build path->Configure Build Path->project Facets
  • 在那里您可以看到一个链接“转换为多面形式”。点击它
  • 标记 java 并从出现在 java 选项卡前面的下拉列表中选择版本 1.7
  • 单击应用并单击确定
  • 现在你可以看到 1.7 版本出现在合规级别

Note:- Before above step you have to add JRE System library in Build path for jdk1.7

注意:- 在上述步骤之前,您必须在 jdk1.7 的构建路径中添加 JRE 系统库

回答by Maciej

I use eclipse 3.6.1 with installed JRE 1.7 and I was able to set Java compliance level to 1.7 (on the workspace level - preferences).
In some workspaces I could do that right in the Preferences, in some workspaces I had to do that in a "hard way" updating several properties in the file: .metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.core.prefs
Here are changed lines: org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.source=1.7 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7

我使用安装了 JRE 1.7 的 eclipse 3.6.1,并且能够将 Java 合规性级别设置为 1.7(在工作区级别 - 首选项)。
在某些工作区中,我可以在首选项中正确执行此操作,在某些工作区中,我必须以“硬方式”更新文件中的几个属性: .metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.core.prefs
以下是更改的行: org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.source=1.7 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7

Maybe it was just enough to change the line with "org.eclipse.jdt.core.compiler.compliance" property , but I did all three for the sake of completeness and consistency.

也许用 "org.eclipse.jdt.core.compiler.compliance" 属性改变行就足够了,但为了完整性和一致性,我做了所有三个。

回答by Light

Right click on project you have in use, click on Properties,

右键单击您正在使用的项目,单击属性,

enter image description herego on "Compiler compilance level", and select 1.8

在此处输入图像描述转到“编译器兼容性级别”,然后选择 1.8

enter image description here

在此处输入图片说明