ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peterrei...@apache.org>
Subject Re: Detecting JDK Version using ANT
Date Thu, 16 Jun 2005 08:25:09 GMT
Zarar Siddiqi wrote:

>Hi,
>
>Is there a clean way to detect what version of Java is being used when running a build
file?
>
>Some possible solutions include:
>
>1) parsing the JAVA_HOME variable to detect the version number
>2) Checking the existence of a file which is specific to a version
>
>Both methods are somewhat brittle.
>
>Is there a sureshot way of knowing whether ANT is being invoked using Java 1.5 or not?
>  
>
It is perhaps more important to check if ant is being invoked using java 
1.5 or higher. The way the
build script used to build ant does this is to check the existance of a 
specific class that has been
introduced in java 1.5.
The snippet from the build file for ant is:
    <available property="jdk1.3+" classname="java.lang.StrictMath"/>
    <available property="jdk1.4+" classname="java.lang.CharSequence"/>
    <available property="jdk1.5+" classname="java.lang.Readable"/>

Peter

>Thanks in advance,
>Zarar
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message