Search code examples
javaeclipseant

Ant use old jdk - how to change it?


I have eclipse indigo (3.7.2) on Ubuntu 12.04 64 bit and I try to compile project using java 1.7. I think I have installed java 1.7 properly because, I can run processing 2.0 (which use java 1.7) and I get correct version message:

prokop@prokop-Precision-T1500:~$ java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

however, when hit "play" in Ant in eclipse I get following message:

 Unsupported major.minor version 51.0

also in header caption of "Console" window of ant build output is :

[Ant Build] /usr/lib/jvm/java-6-openjdk/bin/java

I tried to modify environment settings of eclipse:

  • Project > Properties > Java Compiler to 1.7
  • Window > Prefferences > Java > Installed JREs to jdk1.7._60 which I downloaded to my home /home/prokop/SW/jdk1.7.0_60

but it does not help - ant is oviously still using java-6-openjdk

  • Is there any other setting how to say Ant to use jdk1.7 ?
  • Is it possible at all to make eclipse indigo (3.7.2) on Ubuntu 12.04 64 bit force to compile with java 1.7 ?

Solution

  • This occurs when you run ant via eclipse. You can set JDK using External tools configuration in Eclipse. See the attachment.

    External tools configuration in eclipse