# Ant User Manual

## Available

### Description

Sets a property if a resource is available at runtime. This resource can be a file resource, a class in classpath or a JVM system resource.

If the resource is present, the property value is set to true by default, otherwise the property is not set. You can set the value to something specific by using the value attribute.

Normally, this task is used to set properties that are useful to avoid target execution depending on system parameters.

### Parameters

Attribute | Description | Required
property | the name of the property to set. | Yes
value | the value to set the property to. Defaults to "true". | No
classname | the class to look for in classpath. | Yes
resource | the resource to look for in the JVM
file | the file to look for.
classpath | the classpath to use when looking up `classname`. | No
classpathref | the classpath to use, given as reference to a path defined elsewhere. | No

### Parameters specified as nested elements

#### classpath

`Available`'s classpath attribute is a path-like structure and can also be set via a nested classpath element.

### Examples

      <available classname="org.whatever.Myclass" property="Myclass.present"/>

sets the property `Myclass.present` to the value "true" if the class org.whatever.Myclass is found in Ant's classpath.

    <property name="jaxp.jar" value="./lib/jaxp11/jaxp.jar"/>
    <available file="${jaxp.jar}" property="jaxp.jar.present"/>

sets the property `jaxp.jar.present` to the value "true" if the file ./lib/jaxp11/jaxp.jar is found.

    ...in project ...
    <property name="jaxp.jar" value="./lib/jaxp11/jaxp.jar"/>
    <path id="jaxp" location="${jaxp.jar}"/>
    ...in target ...
    <available classname="javax.xml.transform.Transformer" classpathref="jaxp" property="jaxp11.present"/>

sets the property `jaxp11.present` to the value "true" if the class javax.xml.transform.Transformer is found in the classpath referenced by `jaxp` (in this case, it is `./lib/jaxp11/jaxp.jar`).

Copyright © 2000,2001 Apache Software Foundation. All rights Reserved.