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.
If you are not using eclipse. Then you can change the ant java property directly on the file as mentioned here.
http://pissedoff-techie.blogspot.in/2014/09/ant-picks-up-incorrect-java-version.html