Java (Apache Ant API)
Keywords: org.apache.tools.ant.taskdefs.Java class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tools.ant.taskdefs
Class Java

    java.lang.Object
      org.apache.tools.ant.ProjectComponent
          org.apache.tools.ant.Task
              org.apache.tools.ant.taskdefs.Java

Direct Known Subclasses:
  StyleBook, Test

public class Java
extends Task

Launcher for Java applications. Allows use of the same JVM for the called application thus resulting in much faster operation.

Since:
  Ant 1.1
Author:
  Stefano Mazzocchi stefano@apache.org, Stefan Bodewig

Field Summary

Fields inherited from class org.apache.tools.ant.Task
`description, location, target, taskName, taskType, wrapper`

Fields inherited from class org.apache.tools.ant.ProjectComponent
`project`

Constructor Summary
`Java()`

Method Summary
`void` | `addEnv(Environment.Variable var)` Adds an environment variable.
`void` | `addSysproperty(Environment.Variable sysp)` Adds a system property.
`void` | `clearArgs()` Clear out the arguments to this java task.
`Commandline.Argument` | `createArg()` Adds a command-line argument.
`Path` | `createClasspath()` Adds a path to the classpath.
`Commandline.Argument` | `createJvmarg()` Adds a JVM argument.
`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.
`protected void` | `handleErrorFlush(java.lang.String line)` Pass output sent to System.err to specified output file.
`protected void` | `handleErrorOutput(java.lang.String line)` Pass output sent to System.err to specified output file.
`protected void` | `handleFlush(java.lang.String line)` Pass output sent to System.out to specified output file.
`protected void` | `handleOutput(java.lang.String line)` Pass output sent to System.out to specified output file.
`protected void` | `run(java.lang.String classname, java.util.Vector args)` Executes the given classname with the given arguments as it was a command line application.
`void` | `setAppend(boolean append)` If true, append output to existing file.
`void` | `setArgs(java.lang.String s)` Deprecated: use nested arg instead.
`void` | `setClassname(java.lang.String s)` Sets the Java class to execute.
`void` | `setClasspath(Path s)` Set the classpath to be used when running the Java class
`void` | `setClasspathRef(Reference r)` Classpath to use, by reference.
`void` | `setDir(java.io.File d)` The working directory of the process
`void` | `setFailonerror(boolean fail)` If true, then fail if the command exits with a returncode other than 0
`void` | `setFork(boolean s)` If true, execute in a new VM.
`void` | `setJar(java.io.File jarfile)` The location of the JAR file to execute.
`void` | `setJvm(java.lang.String s)` Set the command used to start the VM (only if not forking).
`void` | `setJvmargs(java.lang.String s)` Set the command line arguments for the JVM.
`void` | `setJVMVersion(java.lang.String value)` Sets the JVM version.
`void` | `setMaxmemory(java.lang.String max)` Corresponds to -mx or -Xmx depending on VM version.
`void` | `setNewenvironment(boolean newenv)` If true, use a completely new environment.
`void` | `setOutput(java.io.File out)` File the output of the process is redirected to.
`void` | `setTimeout(java.lang.Long value)` Timeout in milliseconds after which the process will be killed.

Methods inherited from class org.apache.tools.ant.Task
`getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName`

Methods inherited from class org.apache.tools.ant.ProjectComponent
`getProject, setProject`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Java

    public Java()

Method Detail

### execute

    public void execute()
                 throws BuildException

  Do the execution.

  Overrides:
    `execute` in class `Task`
  Throws:
    `BuildException` - if something goes wrong with the build

### executeJava

    public int executeJava()
                    throws BuildException

  Do the execution and return a return code.

  Returns:
    the return code from the execute java class if it was executed in a separate VM (fork = "yes").
  Throws:
    `BuildException`

### setClasspath

    public void setClasspath(Path s)

  Set the classpath to be used when running the Java class

  Parameters:
    `s` - an Ant Path object containing the classpath.

### createClasspath

    public Path createClasspath()

  Adds a path to the classpath.

### setClasspathRef

    public void setClasspathRef(Reference r)

  Classpath to use, by reference.

### setJar

    public void setJar(java.io.File jarfile)
                throws BuildException

  The location of the JAR file to execute.

  Throws:
    `BuildException`

### setClassname

    public void setClassname(java.lang.String s)
                      throws BuildException

  Sets the Java class to execute.

  Throws:
    `BuildException`

### setArgs

    public void setArgs(java.lang.String s)

  Deprecated: use nested arg instead. Set the command line arguments for the class.

### createArg

    public Commandline.Argument createArg()

  Adds a command-line argument.

### setFork

    public void setFork(boolean s)

  If true, execute in a new VM.

### setJvmargs

    public void setJvmargs(java.lang.String s)

  Set the command line arguments for the JVM.

### createJvmarg

    public Commandline.Argument createJvmarg()

  Adds a JVM argument.

### setJvm

    public void setJvm(java.lang.String s)

  Set the command used to start the VM (only if not forking).

### addSysproperty

    public void addSysproperty(Environment.Variable sysp)

  Adds a system property.

### setFailonerror

    public void setFailonerror(boolean fail)

  If true, then fail if the command exits with a returncode other than 0

### setDir

    public void setDir(java.io.File d)

  The working directory of the process

### setOutput

    public void setOutput(java.io.File out)

  File the output of the process is redirected to.

### setMaxmemory

    public void setMaxmemory(java.lang.String max)

  Corresponds to -mx or -Xmx depending on VM version.

### setJVMVersion

    public void setJVMVersion(java.lang.String value)

  Sets the JVM version.

  Parameters:
    `value` - JVM version

### addEnv

    public void addEnv(Environment.Variable var)

  Adds an environment variable.

  Will be ignored if we are not forking a new VM.

  Since:
    Ant 1.5

### setNewenvironment

    public void setNewenvironment(boolean newenv)

  If true, use a completely new environment.

  Will be ignored if we are not forking a new VM.

  Since:
    Ant 1.5

### setAppend

    public void setAppend(boolean append)

  If true, append output to existing file.

  Since:
    Ant 1.5

### setTimeout

    public void setTimeout(java.lang.Long value)

  Timeout in milliseconds after which the process will be killed.

  Since:
    Ant 1.5

### handleOutput

    protected void handleOutput(java.lang.String line)

  Pass output sent to System.out to specified output file.

  Overrides:
    `handleOutput` in class `Task`
  Parameters:
    `line` - The line of output to log. Should not be `null`.
  Since:
    Ant 1.5

### handleFlush

    protected void handleFlush(java.lang.String line)

  Pass output sent to System.out to specified output file.

  Overrides:
    `handleFlush` in class `Task`
  Parameters:
    `line` - The line of output to log. Should not be `null`.
  Since:
    Ant 1.5.2

### handleErrorOutput

    protected void handleErrorOutput(java.lang.String line)

  Pass output sent to System.err to specified output file.

  Overrides:
    `handleErrorOutput` in class `Task`
  Parameters:
    `line` - The error line to log. Should not be `null`.
  Since:
    Ant 1.5

### handleErrorFlush

    protected void handleErrorFlush(java.lang.String line)

  Pass output sent to System.err to specified output file.

  Overrides:
    `handleErrorFlush` in class `Task`
  Parameters:
    `line` - The error line to log. Should not be `null`.
  Since:
    Ant 1.5.2

### run

    protected void run(java.lang.String classname,
                       java.util.Vector args)
                throws BuildException

  Executes the given classname with the given arguments as it was a command line application.

  Throws:
    `BuildException`

### clearArgs

    public void clearArgs()

  Clear out the arguments to this java task.

### createWatchdog

    protected ExecuteWatchdog createWatchdog()
                                      throws BuildException

  Create the Watchdog to kill a runaway process.

  Throws:
    `BuildException`
  Since:
    Ant 1.5

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.