I\'m using Ant 1.7.0 and installed java 1.6 which is in JAVA_HOME.
I want to build a project using java 1.5, so I\'ve exported JAVA_HOME to be my java 1.5 directory.
In Eclipse:
Right click on your build.xml
click "Run As", click on "External Tool Configurations..."
Select tab JRE. Select the JRE you are using.
Re-run the task, it should be fine now.