简体   繁体   English

升级Eclipse java编译器

[英]Upgrade Eclipse java compiler

I started using Ant, that ships with Eclipse. 我开始使用随Eclipse一起提供的Ant。 It annoys me, that I get hundreds of warnings in the lines of: 令我很恼火的是,我得到了数以百计的警告:

[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]警告:java \\ io \\ BufferedInputStream.class(java \\ io:BufferedInputStream.class):主要版本51比50更新,是此编译器支持的最高主要版本。
[javac] It is recommended that the compiler be upgraded. [javac]建议升级编译器。

How do I upgrade compiler? 如何升级编译器?

download and install newer version of JDK. 下载并安装较新版本的JDK。

Windows - > Preference - > Java - > Installed JRE set newer version here Windows - > Preference - > Java - > Installed JRE在此处设置较新版本

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. 主要版本51是Java 7 - 看起来您正在针对预览Java 7 API库进行开发,但使用Java 6 javac进行编译。 Either make sure ant uses the Java 7 compiler, or use a Java 6 API library to compile against. 确保ant使用Java 7编译器,或使用Java 6 API库进行编译。

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 Jars and put your tools.jar here. 单击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

您可能还需要考虑此StackOverflow问题的已接受答案: 在使用较旧的JDK库时将Eclipse ant降级为编译(Java 1.7 - > 1.6)

Follow these steps: 跟着这些步骤:

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

If there is a broken link with a jar in previous JDK, Eclipse will notify you. 如果以前的JDK中存在与jar的链接断开,Eclipse将通知您。 I solved in this way the problem with tools.jar ant reference, but it is a general way to find the solution. 我用这种方式解决了tools.jar ant引用的问题,但它是查找解决方案的一般方法。

由于我的开发环境应该基于Java 6,唯一有助于解决这个问题的就是删除Java 7

I solved my warning with answer from Bao. 我用宝的回答解决了我的警告。 I had JDK1.6 installed before. 我以前安装过JDK1.6。 Then installed JDK1.7 and ant was stil using JKD1.6 for compiling. 然后使用JKD1.6安装JDK1.7和ant stil进行编译。

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。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM