I have installed two jdks - jdk 1.5 and jdk 1.8. I have following Ant build.xml config file :
I had this same issue. I had JAVA_HOME and JRE_HOME set correctly. I also had Ant > 1.9.
What I did to fix it is go into Eclipse to Window -> Preferences. Expand Ant and select Runtime. By default the Classpath tab should be selected and on the right hand side there is a button called "Ant Home". Click this button and double check it is pointed to your Ant folder.