org.apache.tools.ant.taskdefs
public class Java extends Task
Since: Ant 1.1
UNKNOWN: category="java"
Field Summary | |
---|---|
protected Redirector | redirector |
protected RedirectorElement | redirectorElement |
Constructor Summary | |
---|---|
Java()
Normal constructor | |
Java(Task owner)
create a bound task |
Method Summary | |
---|---|
void | addAssertions(Assertions asserts)
Add assertions to enable in this program (if fork=true). |
void | addConfiguredRedirector(RedirectorElement redirectorElement)
Add a RedirectorElement to this task. |
void | addEnv(Environment.Variable var)
Add an environment variable.
|
void | addSysproperty(Environment.Variable sysp)
Add a system property.
|
void | addSyspropertyset(PropertySet sysp)
Add a set of properties as system properties.
|
void | clearArgs()
Clear out the arguments to this java task. |
Commandline.Argument | createArg()
Add a command-line argument.
|
Path | createBootclasspath()
Add a path to the bootclasspath. |
Path | createClasspath()
Add a path to the classpath.
|
Commandline.Argument | createJvmarg()
Adds a JVM argument.
|
Permissions | createPermissions()
Set the permissions for the application run inside the same JVM. |
protected ExecuteWatchdog | createWatchdog()
Create the Watchdog to kill a runaway process.
|
void | execute()
Do the execution. |
int | executeJava()
Do the execution and return a return code.
|
CommandlineJava | getCommandLine()
Accessor to the command line.
|
CommandlineJava.SysProperties | getSysProperties()
Get the system properties of the command line.
|
protected void | handleErrorFlush(String output)
Handle output sent to System.err and flush the stream.
|
protected void | handleErrorOutput(String output)
Handle output sent to System.err.
|
protected void | handleFlush(String output)
Pass output sent to System.out to specified output file.
|
int | handleInput(byte[] buffer, int offset, int length)
Handle an input request by this task.
|
protected void | handleOutput(String output)
Pass output sent to System.out to specified output file.
|
protected void | maybeSetResultPropertyValue(int result)
Helper method to set result property to the
passed in value if appropriate.
|
protected void | run(String classname, Vector args)
Executes the given classname with the given arguments as if it
were a command line application.
|
void | setAppend(boolean append)
If true, append output to existing file.
|
void | setArgs(String s)
Deprecated: use nested arg instead.
|
void | setClassname(String s)
Set the Java class to execute.
|
void | setClasspath(Path s)
Set the classpath to be used when running the Java class.
|
void | setClasspathRef(Reference r)
Set the classpath to use by reference.
|
void | setCloneVm(boolean cloneVm)
If set, system properties will be copied to the cloned VM--as
well as the bootclasspath unless you have explicitly specified
a bootclaspath.
|
void | setDir(File d)
Set the working directory of the process.
|
void | setError(File error)
Set the File to which the error stream of the process is redirected.
|
void | setErrorProperty(String errorProperty)
Set the property name whose value should be set to the error of
the process.
|
void | setFailonerror(boolean fail)
If true, then fail if the command exits with a
returncode other than zero.
|
void | setFork(boolean s)
If true, execute in a new VM.
|
void | setInput(File input)
Set the input to use for the task.
|
void | setInputString(String inputString)
Set the string to use as input.
|
void | setJar(File jarfile)
Set the location of the JAR file to execute.
|
void | setJvm(String s)
Set the command used to start the VM (only if forking).
|
void | setJvmargs(String s)
Set the command line arguments for the JVM.
|
void | setJVMVersion(String value)
Set the JVM version. |
void | setLogError(boolean logError)
Set whether error output of exec is logged. |
void | setMaxmemory(String max)
Corresponds to -mx or -Xmx depending on VM version.
|
void | setNewenvironment(boolean newenv)
If true, use a completely new environment.
|
void | setOutput(File out)
Set the File to which the output of the process is redirected.
|
void | setOutputproperty(String outputProp)
Set the property name whose value should be set to the output of
the process.
|
void | setResultProperty(String resultProperty)
Set the name of the property in which the return code of the
command should be stored. |
void | setSpawn(boolean spawn)
Set whether or not you want the process to be spawned;
default is not spawned. |
void | setTimeout(Long value)
Set the timeout in milliseconds after which the process will be killed.
|
protected void | setupRedirector()
Set up properties on the redirector that we needed to store locally. |
Parameters: owner owner
Parameters: asserts assertion set.
Since: Ant 1.6
RedirectorElement
to this task.Parameters: redirectorElement RedirectorElement
.
Will be ignored if we are not forking a new VM.
Parameters: var new environment variable.
Since: Ant 1.5
Parameters: sysp system property.
Parameters: sysp set of properties to add.
Since: Ant 1.6
Returns: created argument.
Returns: created bootclasspath.
Since: Ant 1.6
Returns: created classpath.
Returns: JVM argument created.
Returns: Permissions.
Since: Ant 1.6
Returns: new watchdog.
Throws: BuildException under unknown circumstances.
Since: Ant 1.5
Throws: BuildException if failOnError is set to true and the application returns a nonzero result code.
Returns: the return code from the execute java class if it was executed in a separate VM (fork = "yes") or a security manager was installed that prohibits ExitVM (default).
Throws: BuildException if required parameters are missing.
Returns: the current command line.
Since: 1.6.3
Returns: the current properties of this java invocation.
Since: 1.6.3
Parameters: output string of stderr.
Since: Ant 1.5.2
Parameters: output string of stderr.
Since: Ant 1.5
Parameters: output string of output on its way to its handlers.
Since: Ant 1.5.2
Parameters: buffer the buffer into which data is to be read. offset the offset into the buffer at which data is stored. length the amount of data to read.
Returns: the number of bytes read.
Throws: IOException if the data cannot be read.
Since: Ant 1.6
Parameters: output a string of output on its way to the handlers.
Since: Ant 1.5
Parameters: result the exit code
Parameters: classname the name of the class to run. args arguments for the class.
Throws: BuildException in case of IOException in the execution.
Parameters: append if true, append output to existing file.
Since: Ant 1.5
Parameters: s arguments.
UNKNOWN: ignore="true"
Parameters: s the name of the main class.
Throws: BuildException if the jar attribute has been set.
Parameters: s an Ant Path object containing the classpath.
Parameters: r a reference to an existing classpath.
Doesn't have any effect unless fork is true.
Parameters: cloneVm if true copy system properties.
Since: Ant 1.7
Parameters: d working directory.
Parameters: error file getting the error stream.
Since: Ant 1.6
Parameters: errorProperty property name.
Since: Ant 1.6
Parameters: fail if true fail the build when the command exits with a nonzero returncode.
Parameters: s do you want to run Java in a new VM.
Parameters: input name of the input file.
Parameters: inputString the string which is used as the input source.
Parameters: jarfile the jarfile to execute.
Throws: BuildException if there is also a main class specified.
Parameters: s command to start the VM.
Parameters: s jvmargs.
Parameters: value JVM version.
Parameters: logError get in the ant log the messages coming from stderr in the case that fork = true.
Parameters: max max memory parameter.
Will be ignored if we are not forking a new VM.
Parameters: newenv if true, use a completely new environment.
Since: Ant 1.5
Parameters: out the output File.
Parameters: outputProp property name.
Parameters: resultProperty name of property.
Since: Ant 1.6
Parameters: spawn if true you do not want Ant to wait for the end of the process.
Since: Ant 1.6
Parameters: value timeout in milliseconds.
Since: Ant 1.5