org.apache.tools.ant.taskdefs

## Class ExecuteJava

- java.lang.Object
- - org.apache.tools.ant.taskdefs.ExecuteJava

- All Implemented Interfaces:
    java.lang.Runnable, TimeoutObserver

      public class ExecuteJava
      extends java.lang.Object
      implements java.lang.Runnable, TimeoutObserver

  Execute a Java class.
  Since:
    Ant 1.2

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExecuteJava()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `execute(Project project)` Execute the Java class against the specified Ant Project.
    `int` | `fork(ProjectComponent 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.
    `boolean` | `killedProcess()` Get whether the process was killed.
    `void` | `run()` Run this ExecuteJava in a Thread.
    `void` | `setClasspath(Path p)` Set the classpath to be used when running the Java class.
    `void` | `setJavaCommand(Commandline javaCommand)` Set the Java "command" for this ExecuteJava.
    `void` | `setOutput(java.io.PrintStream out)` Deprecated. since 1.4.x. manage output at the task level.
    `void` | `setPermissions(Permissions permissions)` Set the permissions for the application run.
    `void` | `setSystemProperties(CommandlineJava.SysProperties s)` Set the system properties to use when running the Java class.
    `void` | `setTimeout(java.lang.Long timeout)` Set the timeout for this ExecuteJava.
    `static void` | `setupCommandLineForVMS(Execute exe, java.lang.String[] command)` On VMS platform, we need to create a special java options file containing the arguments and classpath for the java command.
    `void` | `timeoutOccured(Watchdog w)` Mark timeout as having occurred.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ExecuteJava

          public ExecuteJava()

  - ### Method Detail

    - #### setJavaCommand

          public void setJavaCommand(Commandline javaCommand)

      Set the Java "command" for this ExecuteJava.
      Parameters:
        `javaCommand` - the classname and arguments in a Commandline.

    - #### setClasspath

          public void setClasspath(Path p)

      Set the classpath to be used when running the Java class.
      Parameters:
        `p` - an Ant Path object containing the classpath.

    - #### setSystemProperties

          public void setSystemProperties(CommandlineJava.SysProperties s)

      Set the system properties to use when running the Java class.
      Parameters:
        `s` - CommandlineJava system properties.

    - #### setPermissions

          public void setPermissions(Permissions permissions)

      Set the permissions for the application run.
      Parameters:
        `permissions` - the Permissions to use.
      Since:
        Ant 1.6

    - #### setOutput

          @Deprecated
          public void setOutput(java.io.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` - the PrintStream where output should be sent.

    - #### setTimeout

          public void setTimeout(java.lang.Long timeout)

      Set the timeout for this ExecuteJava.
      Parameters:
        `timeout` - timeout as Long.
      Since:
        Ant 1.5

    - #### execute

          public void execute(Project project)
                       throws BuildException

      Execute the Java class against the specified Ant Project.
      Parameters:
        `project` - the Project to use.
      Throws:
        `BuildException` - on error.

    - #### run

          public void run()

      Run this ExecuteJava in a Thread.
      Specified by:
        `run` in interface `java.lang.Runnable`
      Since:
        Ant 1.5

    - #### timeoutOccured

          public void timeoutOccured(Watchdog w)

      Mark timeout as having occurred.
      Specified by:
        `timeoutOccured` in interface `TimeoutObserver`
      Parameters:
        `w` - the responsible Watchdog.
      Since:
        Ant 1.5

    - #### killedProcess

          public boolean killedProcess()

      Get whether the process was killed.
      Returns:
        `true` if the process was killed, false otherwise.
      Since:
        1.19, Ant 1.5

    - #### fork

          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` - the ProjectComponent to use for logging, etc.
      Returns:
        the exit status of the subprocess.
      Throws:
        `BuildException` - on error.
      Since:
        Ant 1.6.3

    - #### setupCommandLineForVMS

          public static void setupCommandLineForVMS(Execute exe,
                                                    java.lang.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` - the Execute instance to alter.
        `command` - the command-line.