Home » Apache Ant Java Task

Apache Ant Java Task

by Online Tutorials Library

Apache Ant Java Task

This task is used to execute Java code inside the Ant JVM. We can also use other (outside) JVM by setting fork attribute true.

To get input for the fork JVM, we can use input and inputstring attributes.

Apache Ant Java Task Attributes

Attribute Description Required
classname A Java class which is to be executed. Exactly one of the three
jar Jar file with location.
module Main module name to resolve.
args The arguments for the class that is executed. No
classpath The classpath to use. No
classpathref The classpath to use with path reference. No
modulepath It is used to specify module path. No
modulepathref The modulepath with path reference. No
fork If enabled triggers the class execution in another JVM. No
spawn It is used to allow to start a process which will outlive Ant. No
jvm It is a command used to run JVM. No
jvmargs The JVM arguments, passed to the JVM. No
maxmemory Max amount of memory to allocate to the forked JVM. No
failonerror It stops the build process. No
resultproperty The name of a property in which the return code of the command should be stored. No
dir The directory to be include in run. No
output Output file name. No
error Error file name. No
logError To get errors log, store into a file. No
append Whether output and error files should be appended to or overwritten./td> No
outputproperty A property in which the output of the command should be stored. No
errorproperty A property in which the standard error of the command should be stored. No

Apache Ant Java Task Example

This example will run the a Java class Hello.

Run the JAR with maximum memory 128 MB.

You may also like