简体   繁体   中英

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?

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"

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.

I would check PATH environment variable.

What do you get when you on a clean shell (recently started) execute:

$ java -version

Ant probably thinks you are trying to user OpenJDK's JVM and compiler (I think it comes installed with RH). Try uninstalling that too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM