Launcher for Java applications. Allows use of
the same JVM for the called application thus resulting in much
faster operation.
addAssertions
public void addAssertions(Assertions asserts)
Add assertions to enable in this program (if fork=true).
addConfiguredRedirector
public void addConfiguredRedirector(RedirectorElement redirectorElement)
Add a RedirectorElement
to this task.
redirectorElement
- RedirectorElement
.
addEnv
public void addEnv(Environment.Variable var)
Add an environment variable.
Will be ignored if we are not forking a new VM.
var
- new environment variable.
addSyspropertyset
public void addSyspropertyset(PropertySet sysp)
Add a set of properties as system properties.
sysp
- set of properties to add.
clearArgs
public void clearArgs()
Clear out the arguments to this java task.
createBootclasspath
public Path createBootclasspath()
Add a path to the bootclasspath.
createClasspath
public Path createClasspath()
Add a path to the classpath.
createPermissions
public Permissions createPermissions()
Set the permissions for the application run inside the same JVM.
executeJava
public int executeJava()
throws BuildException
Do the execution and return a return code.
- 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).
getCommandLine
public CommandlineJava getCommandLine()
Accessor to the command line.
- the current command line.
getSysProperties
public CommandlineJava.SysProperties getSysProperties()
Get the system properties of the command line.
- the current properties of this java invocation.
handleErrorFlush
protected void handleErrorFlush(String output)
Handle output sent to System.err and flush the stream.
- handleErrorFlush in interface Task
output
- string of stderr.
handleErrorOutput
protected void handleErrorOutput(String output)
Handle output sent to System.err.
- handleErrorOutput in interface Task
output
- string of stderr.
handleFlush
protected void handleFlush(String output)
Pass output sent to System.out to specified output file.
- handleFlush in interface Task
output
- string of output on its way to its handlers.
handleInput
public int handleInput(byte[] buffer,
int offset,
int length)
throws IOException
Handle an input request by this task.
- handleInput in interface Task
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.
- the number of bytes read.
handleOutput
protected void handleOutput(String output)
Pass output sent to System.out to specified output file.
- handleOutput in interface Task
output
- a string of output on its way to the handlers.
maybeSetResultPropertyValue
protected void maybeSetResultPropertyValue(int result)
Helper method to set result property to the
passed in value if appropriate.
run
protected void run(String classname,
Vector args)
throws BuildException
Executes the given classname with the given arguments as if it
were a command line application.
classname
- the name of the class to run.args
- arguments for the class.
setAppend
public void setAppend(boolean append)
If true, append output to existing file.
append
- if true, append output to existing file.
setArgs
public void setArgs(String s)
Deprecated: use nested arg instead.
Set the command line arguments for the class.
setClassname
public void setClassname(String s)
throws BuildException
Set the Java class to execute.
s
- the name of the main class.
setClasspath
public void setClasspath(Path s)
Set the classpath to be used when running the Java class.
s
- an Ant Path object containing the classpath.
setClasspathRef
public void setClasspathRef(Reference r)
Set the classpath to use by reference.
r
- a reference to an existing classpath.
setCloneVm
public 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.
Doesn't have any effect unless fork is true.
cloneVm
- if true copy system properties.
setDir
public void setDir(File d)
Set the working directory of the process.
setError
public void setError(File error)
Set the File to which the error stream of the process is redirected.
error
- file getting the error stream.
setErrorProperty
public void setErrorProperty(String errorProperty)
Set the property name whose value should be set to the error of
the process.
errorProperty
- property name.
setFailonerror
public void setFailonerror(boolean fail)
If true, then fail if the command exits with a
returncode other than zero.
fail
- if true fail the build when the command exits with a
nonzero returncode.
setFork
public void setFork(boolean s)
If true, execute in a new VM.
s
- do you want to run Java in a new VM.
setInput
public void setInput(File input)
Set the input to use for the task.
input
- name of the input file.
setInputString
public void setInputString(String inputString)
Set the string to use as input.
inputString
- the string which is used as the input source.
setJVMVersion
public void setJVMVersion(String value)
Set the JVM version.
setJar
public void setJar(File jarfile)
throws BuildException
Set the location of the JAR file to execute.
jarfile
- the jarfile to execute.
setJvm
public void setJvm(String s)
Set the command used to start the VM (only if forking).
s
- command to start the VM.
setJvmargs
public void setJvmargs(String s)
Set the command line arguments for the JVM.
setLogError
public void setLogError(boolean logError)
Set 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.
logError
- get in the ant log the messages coming from stderr
in the case that fork = true.
setMaxmemory
public void setMaxmemory(String max)
Corresponds to -mx or -Xmx depending on VM version.
max
- max memory parameter.
setNewenvironment
public void setNewenvironment(boolean newenv)
If true, use a completely new environment.
Will be ignored if we are not forking a new VM.
newenv
- if true, use a completely new environment.
setOutput
public void setOutput(File out)
Set the File to which the output of the process is redirected.
setOutputproperty
public void setOutputproperty(String outputProp)
Set the property name whose value should be set to the output of
the process.
outputProp
- property name.
setResultProperty
public void setResultProperty(String resultProperty)
Set the name of the property in which the return code of the
command should be stored. Only of interest if failonerror=false.
resultProperty
- name of property.
setSpawn
public void setSpawn(boolean spawn)
Set whether or not you want the process to be spawned;
default is not spawned.
spawn
- if true you do not want Ant to wait for the end of the process.
setTimeout
public void setTimeout(Long value)
Set the timeout in milliseconds after which the process will be killed.
value
- timeout in milliseconds.
setupRedirector
protected void setupRedirector()
Set up properties on the redirector that we needed to store locally.