<java : Java>

Description

Launcher for Java applications. Allows use of the same JVM for the called application thus resulting in much faster operation.

Parameters

Attribute Description Type Required?
resultproperty The name of a property in which the return code of the command should be stored. Only of interest if failonerror=false. String ?
jvmargs Set the command line arguments for the JVM. String ?
args Deprecated: use nested arg instead. Set the command line arguments for the class. String ?
fork If true, execute in a new VM. boolean ?
maxmemory Corresponds to -mx or -Xmx depending on VM version. String ?
classpathref Classpath to use, by reference. Reference ?
jar The location of the JAR file to execute. File ?
errorproperty Property name whose value should be set to the error of the process. String ?
output File the output of the process is redirected to. File ?
timeout Timeout in milliseconds after which the process will be killed. Long ?
spawn set whether or not you want the process to be spawned default is not spawned boolean ?
jvm Set the command used to start the VM (only if forking). String ?
input Set the input to use for the task File ?
inputstring Set the string to use as input String ?
classpath Set the classpath to be used when running the Java class Path ?
logerror Controls whether error output of exec is logged. This is only useful when output is being redirected and error output is desired in the Ant log boolean ?
dir The working directory of the process File ?
error File the error stream of the process is redirected to. File ?
jvmversion Sets the JVM version. String ?
outputproperty Property name whose value should be set to the output of the process. String ?
failonerror If true, then fail if the command exits with a returncode other than 0 boolean ?
append If true, append output to existing file. boolean ?
newenvironment If true, use a completely new environment.

Will be ignored if we are not forking a new VM.

boolean ?
classname Sets the Java class to execute. String ?

Parameters accepted as nested elements

<classpath> ...

This object represents a path as used by CLASSPATH or PATH environment variable.

<sometask>
  <somepath>
    <pathelement location="/path/to/file.jar" />
    <pathelement path="/path/to/file2.jar:/path/to/class2;/path/to/class3" />
    <pathelement location="/path/to/file3.jar" />
    <pathelement location="/path/to/file4.jar" />
  </somepath>
</sometask>

The object implemention sometask must provide a method called createSomepath which returns an instance of Path. Nested path definitions are handled by the Path object and must be labeled pathelement.

The path element takes a parameter path which will be parsed and split into single elements. It will usually be used to define a path from an environment variable.

Attribute Description Type Required
refid Makes this instance in effect a reference to another Path instance.

You must not set another attribute or nest elements inside this element if you make it a reference.

Reference ?
path Parses a path definition and creates single PathElements. String ?

<sysproperty>

representation of a single env value
Attribute Description Type Required
key set the key String ?
file get the absolute path of a file and assign it to the value File ?
value set the value String ?
path stringify path and assign to the value. The value will contain all path elements separated by the appropriate separator Path ?

<bootclasspath> ...

This object represents a path as used by CLASSPATH or PATH environment variable.

<sometask>
  <somepath>
    <pathelement location="/path/to/file.jar" />
    <pathelement path="/path/to/file2.jar:/path/to/class2;/path/to/class3" />
    <pathelement location="/path/to/file3.jar" />
    <pathelement location="/path/to/file4.jar" />
  </somepath>
</sometask>

The object implemention sometask must provide a method called createSomepath which returns an instance of Path. Nested path definitions are handled by the Path object and must be labeled pathelement.

The path element takes a parameter path which will be parsed and split into single elements. It will usually be used to define a path from an environment variable.

Attribute Description Type Required
refid Makes this instance in effect a reference to another Path instance.

You must not set another attribute or nest elements inside this element if you make it a reference.

Reference ?
path Parses a path definition and creates single PathElements. String ?

<redirector> ...

Element representation of a Redirector.
Attribute Description Type Required
refid Makes this instance in effect a reference to another instance.

You must not set another attribute or nest elements inside this element if you make it a reference.

Reference ?
inputencoding Set the input encoding. String ?
append Whether output should be appended to or overwrite an existing file. Defaults to false. boolean ?
createemptyfiles Whether output and error files should be created even when empty. Defaults to true. boolean ?
output File the output of the process is redirected to. If error is not redirected, it too will appear in the output File ?
outputproperty Property name whose value should be set to the output of the process. String ?
outputencoding Set the output encoding. String ?
errorproperty Property name whose value should be set to the error of the process. String ?
error Set the file to which standard error is to be redirected. File ?
inputstring Set the string to use as input String ?
alwayslog If true, (error and non-error) output will be "teed", redirected as specified while being sent to Ant's logging mechanism as if no redirection had taken place. Defaults to false. boolean ?
input Set the input to use for the task File ?
errorencoding Set the error encoding. String ?
logerror Controls whether error output of exec is logged. This is only useful when output is being redirected and error output is desired in the Ant log boolean ?

<syspropertyset> ...

A set of properties.
Attribute Description Type Required
refid Sets the value of the refid attribute. Reference ?
dynamic Set whether to reevaluate the set everytime the set is used. Default is true. boolean ?
negate Set whether to negate results. If "true", all properties not selected by nested elements will be returned. Default is "false". boolean ?

<env>

representation of a single env value
Attribute Description Type Required
key set the key String ?
file get the absolute path of a file and assign it to the value File ?
value set the value String ?
path stringify path and assign to the value. The value will contain all path elements separated by the appropriate separator Path ?

<permissions> ...

This class implements a security manager meant for useage by tasks that run inside the ant VM. An examples are the Java Task and JUnitTask. The basic functionality is that nothing (except for a base set of permissions) is allowed, unless the permission is granted either explicitly or implicitly. If an permission is granted this can be overruled by explicitly revoking the permission. It is not permissible to add permissions (either granted or revoked) while the Security Manager is active (after calling setSecurityManager() but before calling restoreSecurityManager()).
Attribute Description Type Required

<jvmarg>

Used for nested xml command line definitions.
Attribute Description Type Required
line Line to split into several commandline arguments. String ?
file Sets a single commandline argument to the absolute filename of the given file. File ?
pathref Sets a single commandline argument from a reference to a path - ensures the right separator for the local platform is used. Reference ?
value Sets a single commandline argument. String ?
path Sets a single commandline argument and treats it like a PATH - ensures the right separator for the local platform is used. Path ?

<arg>

Used for nested xml command line definitions.
Attribute Description Type Required
line Line to split into several commandline arguments. String ?
file Sets a single commandline argument to the absolute filename of the given file. File ?
pathref Sets a single commandline argument from a reference to a path - ensures the right separator for the local platform is used. Reference ?
value Sets a single commandline argument. String ?
path Sets a single commandline argument and treats it like a PATH - ensures the right separator for the local platform is used. Path ?

<assertions> ...

The assertion datatype. This type describes assertion settings for the <java> task and others. One can set the system assertions, and enable/disable those in packages and classes. Assertions can only be enabled or disabled when forking Java. Example: set system assertions and all org.apache packages except for ant, and the class org.apache.tools.ant.Main.
 <assertions enableSystemAssertions="true" >
   <enable package="org.apache" />
   <disable package="org.apache.ant" />
   <enable class="org.apache.tools.ant.Main"/>
 </assertions>
Disable system assertions; enable those in the anonymous package
 <assertions enableSystemAssertions="false" >
   <enable package="..." />
 </assertions>
 
enable assertions in a class called Test
 <assertions >
   <enable class="Test" />
 </assertions>
 
This type is a datatype, so you can declare assertions and use them later
 <assertions id="project.assertions" >
   <enable project="org.apache.test" />
 </assertions>

 <assertions refid="project.assertions" />

 
Attribute Description Type Required
refid Set the value of the refid attribute.

Subclasses may need to check whether any other attributes have been set as well or child elements have been created and thus override this method. if they do the must call super.setRefid.

Reference ?
enablesystemassertions enable or disable system assertions Boolean ?