@@ -16,7 +16,9 @@ If odd things go wrong when you run this task, set fork="true" to use a new
JVM.
JVM.
<p>Note that you cannot interact with a forked VM, the only way to
<p>Note that you cannot interact with a forked VM, the only way to
send input to it is via the input and inputstring attributes.</p>
send input to it is via the input and inputstring attributes. Also note that
in Ant 1.6, any attempt to read input in the forked VM will receive an
EOF (-1). This is a change from Ant 1.5, where such an attempt would block.</p>
<h3>Parameters</h3>
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<table border="1" cellpadding="2" cellspacing="0">
@@ -32,7 +34,7 @@ send input to it is via the input and inputstring attributes.</p>
</tr>
</tr>
<tr>
<tr>
<td valign="top">jar</td>
<td valign="top">jar</td>
<td valign="top">the location of the jar file to execute (must have a
<td valign="top">the location of the jar file to execute (must have a
Main-Class entry in the manifest). Fork must be set to true if this option is selected.</td>
Main-Class entry in the manifest). Fork must be set to true if this option is selected.</td>
<td align="center" valign="top">Either jar or classname</td>
<td align="center" valign="top">Either jar or classname</td>
</tr>
</tr>
@@ -97,7 +99,7 @@ send input to it is via the input and inputstring attributes.</p>
</tr>
</tr>
<tr>
<tr>
<td valign="top">resultproperty</td>
<td valign="top">resultproperty</td>
<td valign="top">The name of a property in which the return code of the
<td valign="top">The name of a property in which the return code of the
command should be stored. Only of interest if failonerror=false
command should be stored. Only of interest if failonerror=false
and if fork=true.</td>
and if fork=true.</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">No</td>
@@ -110,7 +112,7 @@ send input to it is via the input and inputstring attributes.</p>
</tr>
</tr>
<tr>
<tr>
<td valign="top">output</td>
<td valign="top">output</td>
<td valign="top">Name of a file to which to write the output. If the error stream
<td valign="top">Name of a file to which to write the output. If the error stream
is not also redirected to a file or property, it will appear in this output.</td>
is not also redirected to a file or property, it will appear in this output.</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">No</td>
</tr>
</tr>
@@ -123,8 +125,8 @@ send input to it is via the input and inputstring attributes.</p>
<tr>
<tr>
<td valign="top">logError</td>
<td valign="top">logError</td>
<td valign="top">This attribute is used when you wish to see error output in Ant's
<td valign="top">This attribute is used when you wish to see error output in Ant's
log and you are redirecting output to a file/property. The error
output will not be included in the output file/property. If you
log and you are redirecting output to a file/property. The error
output will not be included in the output file/property. If you
redirect error with the "error" or "errorProperty"
redirect error with the "error" or "errorProperty"
attributes, this will have no effect.</td>
attributes, this will have no effect.</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">No</td>
@@ -137,14 +139,14 @@ send input to it is via the input and inputstring attributes.</p>
</tr>
</tr>
<tr>
<tr>
<td valign="top">outputproperty</td>
<td valign="top">outputproperty</td>
<td valign="top">The name of a property in which the output of the
<td valign="top">The name of a property in which the output of the
command should be stored. Unless the error stream is redirected to a separate
command should be stored. Unless the error stream is redirected to a separate
file or stream, this property will include the error output.</td>
file or stream, this property will include the error output.</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">No</td>
</tr>
</tr>
<tr>
<tr>
<td valign="top">errorproperty</td>
<td valign="top">errorproperty</td>
<td valign="top">The name of a property in which the standard error of the
<td valign="top">The name of a property in which the standard error of the
command should be stored.</td>
command should be stored.</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">No</td>
</tr>
</tr>
@@ -157,7 +159,7 @@ send input to it is via the input and inputstring attributes.</p>
</tr>
</tr>
<tr>
<tr>
<td valign="top">inputstring</td>
<td valign="top">inputstring</td>
<td valign="top">A string which serves as the input stream for the
<td valign="top">A string which serves as the input stream for the
executed command. This attribute is mutually exclusive with the
executed command. This attribute is mutually exclusive with the
input attribute.</td>
input attribute.</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">No</td>
@@ -180,11 +182,11 @@ send input to it is via the input and inputstring attributes.</p>
<h3>Parameters specified as nested elements</h3>
<h3>Parameters specified as nested elements</h3>
<h4>arg and jvmarg</h4>
<h4>arg and jvmarg</h4>
<p>Use nested <code><arg></code> and <code><jvmarg></code>
<p>Use nested <code><arg></code> and <code><jvmarg></code>
elements to specify arguments for the Java class and the forked VM respectively.
elements to specify arguments for the Java class and the forked VM respectively.
See <a href="../using.html#arg">Command line arguments</a>.</p>
See <a href="../using.html#arg">Command line arguments</a>.</p>
<h4>sysproperty</h4>
<h4>sysproperty</h4>
<p>Use nested <code><sysproperty></code>
<p>Use nested <code><sysproperty></code>
elements to specify system properties required by the class.
elements to specify system properties required by the class.
These properties will be made available to the VM during the execution
These properties will be made available to the VM during the execution
of the class (either ANT's VM or the forked VM). The attributes
of the class (either ANT's VM or the forked VM). The attributes
for this element are the same as for <a href="exec.html#env">environment
for this element are the same as for <a href="exec.html#env">environment
@@ -218,11 +220,11 @@ section about <a href="exec.html#env">exec</a></p>
<p>Settings will be ignored if fork is disabled.</p>
<p>Settings will be ignored if fork is disabled.</p>
<h4>permissions</h4>
<h4>permissions</h4>
<p>Security permissions can be revoked and granted during the execution of the
<p>Security permissions can be revoked and granted during the execution of the
class via a nested <i>permissions</i> element. For more information please
class via a nested <i>permissions</i> element. For more information please
see <a href="../CoreTypes/permissions.html">permissions</a></p>
see <a href="../CoreTypes/permissions.html">permissions</a></p>
<p>When the permission RuntimePermission exitVM has not been granted (or has
<p>When the permission RuntimePermission exitVM has not been granted (or has
been revoked) the System.exit() call will be intercepted
been revoked) the System.exit() call will be intercepted
and treated like indicated in <i>failonerror</i>.</p>
and treated like indicated in <i>failonerror</i>.</p>
<p><a name="failonerror"/>
<p><a name="failonerror"/>
If you specify <code>failonerror="true"</code> and you do not specify permissions,
If you specify <code>failonerror="true"</code> and you do not specify permissions,
@@ -232,7 +234,7 @@ a non zero return code will lead to a <code>BuildException</code>.
<p>Settings will be ignored if fork is enabled.</p>
<p>Settings will be ignored if fork is enabled.</p>
<p><em>since Ant 1.6</em>.</p>
<p><em>since Ant 1.6</em>.</p>
<h3>Errors and return codes</h3>
<h3>Errors and return codes</h3>
By default the return code of a <java> is ignored. Alternatively, you can set <code>resultproperty</code> to the name
By default the return code of a <java> is ignored. Alternatively, you can set <code>resultproperty</code> to the name
of a property and have it assigned to the result code (barring immutability,
of a property and have it assigned to the result code (barring immutability,
@@ -243,9 +245,9 @@ error and would mean the build exits.
, then <code><java></code> <b>must</b> return 0 otherwise the build will exit, as the class was run by the build jvm.</p>
, then <code><java></code> <b>must</b> return 0 otherwise the build will exit, as the class was run by the build jvm.</p>
<h3>Examples</h3>
<h3>Examples</h3>
<pre>
<pre>
<java classname="test.Main">
<java classname="test.Main">
<arg value="-h"/>
<arg value="-h"/>
<classpath>
<classpath>
<pathelement location="dist/test.jar"/>
<pathelement location="dist/test.jar"/>
<pathelement path="${java.class.path}"/>
<pathelement path="${java.class.path}"/>
@@ -254,12 +256,12 @@ error and would mean the build exits.
</pre>
</pre>
Run a class in this JVM with a new jar on the classpath
Run a class in this JVM with a new jar on the classpath
<pre> <java jar="dist/test.jar"
<pre> <java jar="dist/test.jar"
fork="true"
fork="true"
failonerror="true"
failonerror="true"
maxmemory="128m"
maxmemory="128m"
>
>
<arg value="-h"/>
<arg value="-h"/>
<classpath>
<classpath>
<pathelement location="dist/test.jar"/>
<pathelement location="dist/test.jar"/>
<pathelement path="${java.class.path}"/>
<pathelement path="${java.class.path}"/>
@@ -267,14 +269,14 @@ Run a class in this JVM with a new jar on the classpath
</java>
</java>
</pre>
</pre>
Run the jar using the manifest supplied entry point, forking (as required),
Run the jar using the manifest supplied entry point, forking (as required),
and with a maximum memory of 128MB. Any non zero return code breaks the build.
and with a maximum memory of 128MB. Any non zero return code breaks the build.
<pre> <java classname="test.Main"/></pre>
<pre> <java classname="test.Main"/></pre>
<pre> <java classname="test.Main"
<pre> <java classname="test.Main"
fork="yes" >
fork="yes" >
<sysproperty key="DEBUG" value="true"/>
<arg value="-h"/>
<jvmarg value="-Xrunhprof:cpu=samples,file=log.txt,depth=3"/>
<sysproperty key="DEBUG" value="true"/>
<arg value="-h"/>
<jvmarg value="-Xrunhprof:cpu=samples,file=log.txt,depth=3"/>
</java>
</java>
</pre>
</pre>
<strong>Note</strong>: you can not specify the (highly deprecated) MSJVM, "jview.exe" as the
<strong>Note</strong>: you can not specify the (highly deprecated) MSJVM, "jview.exe" as the