Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class ExecuteJava

extends Object
implements Runnable, TimeoutObserver
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.util.TimeoutObserver, java.lang.Runnable
Imports
java.io.File, .IOException, .PrintStream, java.lang.reflect.InvocationTargetException, .Method, .Modifier, org.apache.tools.ant.AntClassLoader, .BuildException, .Project, .ProjectComponent, .Task, org.apache.tools.ant.taskdefs.condition.Os, org.apache.tools.ant.types.Commandline, .CommandlineJava, .Path, .Permissions, org.apache.tools.ant.util.JavaEnvUtils, .TimeoutObserver, .Watchdog

Execute a Java class.
Since
Ant 1.2

Field Summary

Modifier and TypeField and Description
private volatile Throwable
private Path
private boolean
private Commandline
private Method
private Permissions
private CommandlineJava.SysProperties
private Thread
private volatile boolean
private Long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
execute(Project
the Project to use.
project
)

Execute the Java class against the specified Ant Project.

public int

Returns:

the exit status of the subprocess.
fork
(ProjectComponent
the ProjectComponent to use for logging, etc.
pc
)

Run the Java command in a separate VM, this does not give you the full flexibility of the Java task, but may be enough for simple needs.

public synchronized boolean

Returns:

true if the process was killed, false otherwise.
killedProcess
()

Get whether the process was killed.

public void
run()

Implements java.lang.Runnable.run.

Run this ExecuteJava in a Thread.
public void
setClasspath(Path
an Ant Path object containing the classpath.
p
)

Set the classpath to be used when running the Java class.

public void
setJavaCommand(Commandline
the classname and arguments in a Commandline.
javaCommand
)

Set the Java "command" for this ExecuteJava.

public void
setOutput(PrintStream
the PrintStream where output should be sent.
out
)

Deprecated since 1.4.x. manage output at the task level.
Set the stream to which all output (System.out as well as System.err) will be written.
public void
setPermissions(Permissions
the Permissions to use.
permissions
)

Set the permissions for the application run.

public void
setSystemProperties(CommandlineJava.SysProperties
CommandlineJava system properties.
s
)

Set the system properties to use when running the Java class.

public void
setTimeout(Long
timeout as Long.
timeout
)

Set the timeout for this ExecuteJava.

public static void
setupCommandLineForVMS(Execute
the Execute instance to alter.
exe
,
String[]
the command-line.
command
)

On VMS platform, we need to create a special java options file containing the arguments and classpath for the java command.

public synchronized void
timeoutOccured(Watchdog
the responsible Watchdog.
w
)

Implements org.apache.tools.ant.util.TimeoutObserver.timeoutOccured.

Mark timeout as having occurred.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

caughtback to summary
private volatile Throwable caught
classpathback to summary
private Path classpath
doneback to summary
private boolean done
javaCommandback to summary
private Commandline javaCommand
mainback to summary
private Method main
permback to summary
private Permissions perm
sysPropertiesback to summary
private CommandlineJava.SysProperties sysProperties
threadback to summary
private Thread thread
timedOutback to summary
private volatile boolean timedOut
timeoutback to summary
private Long timeout

Constructor Detail

ExecuteJavaback to summary
public ExecuteJava()

Method Detail

executeback to summary
public void execute(Project project) throws BuildException

Execute the Java class against the specified Ant Project.

Parameters
project:Project

the Project to use.

Exceptions
BuildException:
on error.
forkback to summary
public int fork(ProjectComponent pc) throws BuildException

Run the Java command in a separate VM, this does not give you the full flexibility of the Java task, but may be enough for simple needs.

Parameters
pc:ProjectComponent

the ProjectComponent to use for logging, etc.

Returns:int

the exit status of the subprocess.

Exceptions
BuildException:
on error.
Since
Ant 1.6.3
killedProcessback to summary
public synchronized boolean killedProcess()

Get whether the process was killed.

Returns:boolean

true if the process was killed, false otherwise.

Since
1.19, Ant 1.5
runback to summary
public void run()

Implements java.lang.Runnable.run.

Run this ExecuteJava in a Thread.

Annotations
@Override
Since
Ant 1.5
setClasspathback to summary
public void setClasspath(Path p)

Set the classpath to be used when running the Java class.

Parameters
p:Path

an Ant Path object containing the classpath.

setJavaCommandback to summary
public void setJavaCommand(Commandline javaCommand)

Set the Java "command" for this ExecuteJava.

Parameters
javaCommand:Commandline

the classname and arguments in a Commandline.

setOutputback to summary
public void setOutput(PrintStream out)

Deprecated

since 1.4.x. manage output at the task level.

Set the stream to which all output (System.out as well as System.err) will be written.

Parameters
out:PrintStream

the PrintStream where output should be sent.

Annotations
@Deprecated
setPermissionsback to summary
public void setPermissions(Permissions permissions)

Set the permissions for the application run.

Parameters
permissions:Permissions

the Permissions to use.

Since
Ant 1.6
setSystemPropertiesback to summary
public void setSystemProperties(CommandlineJava.SysProperties s)

Set the system properties to use when running the Java class.

Parameters
s:CommandlineJava.SysProperties

CommandlineJava system properties.

setTimeoutback to summary
public void setTimeout(Long timeout)

Set the timeout for this ExecuteJava.

Parameters
timeout:Long

timeout as Long.

Since
Ant 1.5
setupCommandLineForVMSback to summary
public static void setupCommandLineForVMS(Execute exe, String[] command)

On VMS platform, we need to create a special java options file containing the arguments and classpath for the java command. The special file is supported by the "-V" switch on the VMS JVM.

Parameters
exe:Execute

the Execute instance to alter.

command:String[]

the command-line.

timeoutOccuredback to summary
public synchronized void timeoutOccured(Watchdog w)

Implements org.apache.tools.ant.util.TimeoutObserver.timeoutOccured.

Mark timeout as having occurred.

Parameters
w:Watchdog

the responsible Watchdog.

Annotations
@Override
Since
Ant 1.5