10

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?

Margus
  • 19,694
  • 14
  • 55
  • 103

7 Answers7

11

download and install newer version of JDK.

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

jmj
  • 237,923
  • 42
  • 401
  • 438
  • 2
    Already done tried that, along with changing the appropriate paths, yet I still get the warning – arkon Jun 09 '12 at 02:15
  • 1
    if you still got that warning, check your run configuration of your ant file, instead of `Run As -> Ant Build` try the `Run As -> Ant Build...`-option (have a close look at the three little dots at the end). Then check the tab JRE and select the proper (the updated) jre – Martin Frank Sep 01 '15 at 12:38
11

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.

Michael Borgwardt
  • 342,105
  • 78
  • 482
  • 720
9

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

Perception
  • 79,279
  • 19
  • 185
  • 195
Bao
  • 91
  • 1
  • 1
  • This too didn't work for me, my ant path is already pointed to the highest version..still get the warning – arkon Jun 09 '12 at 02:20
2

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.

Greg Bacon
  • 134,834
  • 32
  • 188
  • 245
Dario
  • 21
  • 1
1

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

Alex
  • 7,007
  • 18
  • 69
  • 114
0

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.

Andreas L.
  • 2,805
  • 23
  • 23
0

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.

Jason
  • 3
  • 2
  • 1
    Hi, welcome to SO, Unfortunately this is not an answer. Please add such tips as a comment in future. – Deepend Nov 18 '14 at 13:59