简体   繁体   中英

Upgrade Eclipse java compiler

I started using Ant, that ships with Eclipse. 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] It is recommended that the compiler be upgraded.

How do I upgrade compiler?

download and install newer version of JDK.

Windows - > Preference - > Java - > Installed JRE set newer version here

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.

Thanks, I figured it out.

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

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

Click Add External Jars and put your tools.jar here.

It will look something like 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.
  2. Go to C:/Program files/Java and delete the previous JDK.
  3. Update your JAVA_HOME and PATH Environment Variables with the new JDK.
  4. Open Eclipse and in Windows > Preference > Java > Installed JRE, set newer version here

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.jar ant reference, but it is a general way to find the solution.

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

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.

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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