Eclipse:javac:目标版本 1.6 与默认源版本 1.7 冲突

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21568166/
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-13 09:24:34  来源:igfitidea点击:

Eclipse: javac: target release 1.6 conflicts with default source release 1.7

javaeclipseeclipse-kepler

提问by Clinton Green

I am trying to perform a build on Eclipse Kepler but when I do so I get the following error javac: target release 1.6 conflicts with default source release 1.7

我正在尝试在 Eclipse Kepler 上执行构建,但是当我这样做时,我收到以下错误 javac: target release 1.6 conflicts with default source release 1.7

I have changed the Java Compiler to use 1.6 but this warned me that the default JRE was 1.7. I then went to Installed JREs removed 1.7 and created a new one for 1.6.

我已将 Java 编译器更改为使用 1.6,但这警告我默认 JRE 为 1.7。然后我去安装 JREs 删除了 1.7 并为 1.6 创建了一个新的。

This still gives the sames error. I also saw something about adding -vm and the java path to eclipse.ini but this didnt help either.

这仍然给出相同的错误。我还看到了一些关于将 -vm 和 java 路径添加到 eclipse.ini 的内容,但这也没有帮助。

Does anyone know what to do?

有谁知道该怎么做?

回答by Jay

You may want to check the project or workspace's compiler settings and verify that the Java source and target versions are the same:

您可能需要检查项目或工作区的编译器设置并验证 Java 源版本和目标版本是否相同:

  1. Right click the project in the package explorer and select 'properties'
  2. Select "Java Compiler" in the left pane.
  3. If "Enable project specific settings" is not set, then click on "Configure Workspace Settings..."
  4. Verify that the source and target are 1.6 if that's what you intend to use
  1. 右键单击包资源管理器中的项目并选择“属性”
  2. 在左窗格中选择“Java 编译器”。
  3. 如果未设置“启用项目特定设置”,则单击“配置工作区设置...”
  4. 如果这是您打算使用的,请验证源和目标是否为 1.6

Here's a link to a similar error when using javac from the commandline: Can we use jdk7 javac to compile code with java7 features into java6 bytecode

这是从命令行使用 javac 时出现类似错误的链接: Can we use jdk7 javac to compile code with java7 features into java6 bytecode