Q:

Why does ant think I have an old version of Java?

I am trying to build Groovy from source (on RH Linux) using ant, but for some reason it thinks that my Java version is 1.4, and not 1.6, and thus it won't compile. The offending lines seem to be 
<condition property="groovy.build.vm5">
    <not>
        <contains string="${ant.java.version}" substring="1.4"/>
    </not>
</condition>

in build.xml. 
When I type javac -version on the command line, it displays "javac 1.6.0_11". Any ideas?

A:

Check the value of the environment variables JDK_HOME and JAVA_HOME.
EDIT: "which java" will tell you which Java you're getting when you run java from the command line.  If this tells you, for example, that you're getting "/usr/lib/jvm/java-6-sun/bin/java", you can set "JAVA_HOME" to "/usr/lib/jvm/java-6-sun"

A:

The answer of Jon Bright hints in a good direction: Possibly your installation of ant uses another java-version than the one you access via 'java -version'. This is influenced by the environment-variables JDK_HOME and JAVA_HOME.
EDIT: If these variables are not present, then ant should find the Java from the installation that called ant. But if you set these variables, ant will pick these. So setting this variables to the installation of JDK1.6 should be worth a try. On Linux your Java could be on a subdirectory of /usr/lib/jvm.

