简体   繁体   中英

Ant using wrong Java version

Ant is using Java 1.5, even though I don't have Java 1.5 installed. I have to use ant 1.6.5. It's not a choice to upgrade.

diagnostics has interesting output:

java -version
java version "1.6.0_37"

./apache-ant-1.6.5/bin/ant  -v | grep -i java
Detected Java version: 1.5 in: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

It seems that there is a configuration that forces ant to run java in 1.5 compatibility. I cannot find this configuration anywhere.

Any ideas what is going on?

The oldest ant version I have on my system is 1.7.0 (my organization also has projects that require using an outdated version of ant to build).

If I run ant -v with the following build.xml file:

<?xml version="1.0"?>
<project name="ant-test" default="test">
    <target name="test">
        <echo message="${java.version}" />
    </target>
</project>

Then ant 1.7.0 reports:

Detected Java version: 1.6 in: C:\\Program Files\\Java\\jdk1.8.0_25\\jre

But later on, it displays:

[echo] 1.8.0_25

If I run it with ant 1.8.4 or ant 1.9.3, which I also have installed, it reports:

Detected Java version: 1.8 in: C:\\Program Files\\Java\\jdk1.8.0_25\\jre

As expected. So this is simply a case of an old version of ant which is misreporting the version of Java that it has detected because it doesn't know about newer versions. I don't believe it will actually cause any problems for you building with Java 1.6.0_37.

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