升级Eclipse java编译器

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

Upgrade Eclipse java compiler

javaeclipse

提问by Margus

I started using Ant, that ships with Eclipse. It annoys me, that I get hundreds of warnings in the lines of:

我开始使用 Eclipse 附带的 Ant。令我烦恼的是,我收到了数百条警告:

[javac] warning: java\io\BufferedInputStream.class(java\io:BufferedInputStream.class): major version 51 is newer than 50, the highest major version supported by this compiler.
[javac] It is recommended that the compiler be upgraded.

[javac] 警告:java\io\BufferedInputStream.class(java\io:BufferedInputStream.class): 主版本 51 比 50 新,这是该编译器支持的最高主版本。
[javac] 建议升级编译器。

How do I upgrade compiler?

如何升级编译器?

采纳答案by Jigar Joshi

download and install newer version of JDK.

下载并安装较新版本的JDK。

Windows - > Preference - > Java - > Installed JREset newer version here

Windows - > Preference - > Java - > Installed JRE在这里设置较新的版本

回答by Michael Borgwardt

Major version 51 is Java 7 - looks like you're developing against a preview Java 7 API library but compiling with a Java 6 javac. Either make sure ant uses the Java 7 compiler, or use a Java 6 API library to compile against.

主要版本 51 是 Java 7 - 看起来您正在针对预览版 Java 7 API 库进行开发,但使用 Java 6 javac 进行编译。要么确保 ant 使用 Java 7 编译器,要么使用 Java 6 API 库进行编译。

回答by Bao

Thanks, I figured it out.

谢谢,我想通了。

For those whom it may concern, to make sure Ant uses the Java 7 compiler:

对于那些可能关心的人,要确保 Ant 使用 Java 7 编译器:

Preferences -> Ant -> Runtime -> Classpath -> Global Entries

Click Add External Jarsand put your tools.jarhere.

单击Add External Jars并将您的放在tools.jar此处。

It will look something like C:\Program Files\Java\jdk1.7.0_03\lib

它看起来像 C:\Program Files\Java\jdk1.7.0_03\lib

回答by Dario

Follow these steps:

按着这些次序:

  1. Download last JDK and install it.
  2. Go to C:/Program files/Javaand delete the previousJDK.
  3. Update your JAVA_HOMEand PATHEnvironment Variables with the new JDK.
  4. Open Eclipse and in Windows > Preference > Java > Installed JRE, set newer version here
  1. 下载最后一个JDK并安装它。
  2. 转到C:/Program files/Java并删除以前的JDK。
  3. 更新JAVA_HOMEPATH与新的JDK的环境变量。
  4. 打开 Eclipse 并在 Windows > Preference > Java > Installed JRE 中,在此处设置较新的版本

If there is a broken link with a jar in previous JDK, Eclipse will notify you. I solved in this way the problem with tools.jarant reference, but it is a general way to find the solution.

如果以前的 JDK 中的 jar 链接断开,Eclipse 会通知您。我是用tools.jarant引用的这种方式解决了这个问题,不过是一般的求解方法。

回答by Andreas L.

I solved my warning with answer from Bao. I had JDK1.6 installed before. Then installed JDK1.7 and ant was stil using JKD1.6 for compiling.

我用鲍的回答解决了我的警告。我之前安装了JDK1.6。然后安装了JDK1.7,ant仍然使用JKD1.6进行编译。

What I have changed is also set the JDK for the project: right click on project > properties > Java Build Path

我所做的更改还为项目设置了 JDK:右键单击项目 > 属性 > Java 构建路径

If you have JDK1.6 here, try to change it to JDK1.7.

如果您这里有JDK1.6,请尝试将其更改为JDK1.7。

回答by Alex

Since my development environment should be based on Java 6 the only thing that helped for this problem was removing Java 7 at all

由于我的开发环境应该基于 Java 6,因此唯一有助于解决此问题的方法就是完全删除 Java 7

回答by Jason

One additional thing you probably also need to do is to go under the JRE tab of the Edit Configuration window and select the JRE version.

您可能还需要做的另一件事是进入“编辑配置”窗口的 JRE 选项卡下并选择 JRE 版本。