CommandlineJava (Apache Ant API)
Keywords: org.apache.tools.ant.types.CommandlineJava,CommandlineJava 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.types
Class CommandlineJava

    java.lang.Object
      |
      +--org.apache.tools.ant.types.CommandlineJava

All Implemented Interfaces:
  java.lang.Cloneable

public class CommandlineJava
extends java.lang.Object
implements java.lang.Cloneable

A representation of a Java command line that is a composite of 2 `Commandline`. One is used for the vm/options and one for the classname/arguments. It provides specific methods for a java command line.

Nested Class Summary
`static class` | `CommandlineJava.SysProperties` Specialized Environment class for System properties

Constructor Summary
`CommandlineJava()` constructor uses the VM we are running on now.

Method Summary
`void` | `addSysproperties(CommandlineJava.SysProperties sysp)` add a set of system properties
`void` | `addSysproperty(Environment.Variable sysp)` add a system property
`void` | `addSyspropertyset(PropertySet sysp)` add a set of system properties
`void` | `clearJavaArgs()` Clear out the java arguments.
`java.lang.Object` | `clone()` clone the object; clone of all fields in the class
`Commandline.Argument` | `createArgument()` create a new argument to the java program
`Path` | `createBootclasspath(Project p)` Create a boot classpath.
`Path` | `createClasspath(Project p)` Create a classpath.
`Commandline.Argument` | `createVmArgument()` create a new JVM argument
`java.lang.String` | `describeCommand()` Returns a String that describes the command and arguments suitable for verbose output before a call to `Runtime.exec(String[])```
`java.lang.String` | `describeJavaCommand()` Returns a String that describes the java command and arguments for in VM executions.
`protected Commandline` | `getActualVMCommand()` Get the VM command parameters, including memory settings
`Assertions` | `getAssertions()` get the current assertions
`Path` | `getBootclasspath()` get the boot classpath
`java.lang.String` | `getClassname()`
`Path` | `getClasspath()` get the classpath for the command
`java.lang.String[]` | `getCommandline()` get the command line to run a java vm.
`java.lang.String` | `getJar()`
`Commandline` | `getJavaCommand()` get the Java command to be used.
`CommandlineJava.SysProperties` | `getSystemProperties()` get the system properties object
`Commandline` | `getVmCommand()` Get the VM command, including memory.
`java.lang.String` | `getVmversion()` Get the vm version.
`protected boolean` | `haveBootclasspath(boolean log)` Has the bootclasspath been specified and shall it really be used (build.sysclasspath could be set or the VM may not support it)?
`protected boolean` | `haveClasspath()` Has the classpath been specified and shall it really be used or will build.sysclasspath null it?
`void` | `restoreSystemProperties()`
`void` | `setAssertions(Assertions assertions)` add an assertion set to the command
`void` | `setClassname(java.lang.String classname)` set the classname to execute
`void` | `setJar(java.lang.String jarpathname)` set a jar file to execute via the -jar option.
`void` | `setMaxmemory(java.lang.String max)` Specify max memory of the JVM -mx or -Xmx depending on VM version
`void` | `setSystemProperties()` cache current system properties and set them to those in this java command
`void` | `setVm(java.lang.String vm)` Set the executable used to start the new JVM.
`void` | `setVmversion(java.lang.String value)` Set the JVM version required.
`int` | `size()` Deprecated. please dont use this -it effectively creates the entire command.
`java.lang.String` | `toString()` get a string description.

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

Constructor Detail

### CommandlineJava

    public CommandlineJava()

  constructor uses the VM we are running on now.

Method Detail

### createArgument

    public Commandline.Argument createArgument()

  create a new argument to the java program

  Returns:
    an argument to be configured

### createVmArgument

    public Commandline.Argument createVmArgument()

  create a new JVM argument

  Returns:
    an argument to be configured

### addSysproperty

    public void addSysproperty(Environment.Variable sysp)

  add a system property

  Parameters:
    `sysp` - a property to be set in the JVM

### addSyspropertyset

    public void addSyspropertyset(PropertySet sysp)

  add a set of system properties

  Parameters:
    `sysp` - a set of properties

### addSysproperties

    public void addSysproperties(CommandlineJava.SysProperties sysp)

  add a set of system properties

  Parameters:
    `sysp` - a set of properties
  Since:
    Ant 1.6.3

### setVm

    public void setVm(java.lang.String vm)

  Set the executable used to start the new JVM.

  Parameters:
    `vm` - the executable to use

### setVmversion

    public void setVmversion(java.lang.String value)

  Set the JVM version required.

  Parameters:
    `value` - the version required

### getAssertions

    public Assertions getAssertions()

  get the current assertions

  Returns:
    assertions or null

### setAssertions

    public void setAssertions(Assertions assertions)

  add an assertion set to the command

  Parameters:
    `assertions` - assertions to make

### setJar

    public void setJar(java.lang.String jarpathname)

  set a jar file to execute via the -jar option.

  Parameters:
    `jarpathname` - the pathname of the jar to execute

### getJar

    public java.lang.String getJar()

  Returns:
    the pathname of the jar file to run via -jar option or `null` if there is no jar to run.
  See Also:
    `getClassname()`

### setClassname

    public void setClassname(java.lang.String classname)

  set the classname to execute

  Parameters:
    `classname` - the fully qualified classname.

### getClassname

    public java.lang.String getClassname()

  Returns:
    the name of the class to run or `null` if there is no class.
  See Also:
    `getJar()`

### createClasspath

    public Path createClasspath(Project p)

  Create a classpath.

  Parameters:
    `p` - the project to use to create the path in
  Returns:
    a path to be configured

### createBootclasspath

    public Path createBootclasspath(Project p)

  Create a boot classpath.

  Parameters:
    `p` - the project to use to create the path in
  Returns:
    a path to be configured
  Since:
    Ant 1.6

### getVmversion

    public java.lang.String getVmversion()

  Get the vm version.

  Returns:
    the vm version

### getCommandline

    public java.lang.String[] getCommandline()

  get the command line to run a java vm.

  Returns:
    the list of all arguments necessary to run the vm.

### setMaxmemory

    public void setMaxmemory(java.lang.String max)

  Specify max memory of the JVM -mx or -Xmx depending on VM version

  Parameters:
    `max` - the string to pass to the jvm to specifiy the max memory

### toString

    public java.lang.String toString()

  get a string description.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    the command line as a string

### describeCommand

    public java.lang.String describeCommand()

  Returns a String that describes the command and arguments suitable for verbose output before a call to `Runtime.exec(String[])`

  ``
  Returns:
    the description string
  Since:
    Ant 1.5

### describeJavaCommand

    public java.lang.String describeJavaCommand()

  Returns a String that describes the java command and arguments for in VM executions.

  The class name is the executable in this context.

  Returns:
    the description string
  Since:
    Ant 1.5

### getActualVMCommand

    protected Commandline getActualVMCommand()

  Get the VM command parameters, including memory settings

  Returns:
    the VM command parameters

### size

    public int size()

  Deprecated. please dont use this -it effectively creates the entire command.

  The size of the java command line. This is a fairly intensive operation, as it has to evaluate the size of many components.

  Returns:
    the total number of arguments in the java command line.
  See Also:
    `getCommandline()`

### getJavaCommand

    public Commandline getJavaCommand()

  get the Java command to be used.

  Returns:
    the java command -not a clone.

### getVmCommand

    public Commandline getVmCommand()

  Get the VM command, including memory.

  Returns:
    A deep clone of the instance's VM command, with memory settings added

### getClasspath

    public Path getClasspath()

  get the classpath for the command

  Returns:
    the classpath or null

### getBootclasspath

    public Path getBootclasspath()

  get the boot classpath

  Returns:
    boot classpath or null

### setSystemProperties

    public void setSystemProperties()
                             throws BuildException

  cache current system properties and set them to those in this java command

  Throws:
    `BuildException` - if Security prevented this operation

### restoreSystemProperties

    public void restoreSystemProperties()
                                 throws BuildException

  Throws:
    `BuildException` - if Security prevented this operation, or there was no system properties to restore

### getSystemProperties

    public CommandlineJava.SysProperties getSystemProperties()

  get the system properties object

  Returns:
    The system properties object

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  clone the object; clone of all fields in the class

  Overrides:
    `clone` in class `java.lang.Object`
  Returns:
    a CommandlineJava object
  Throws:
    `BuildException` - if anything went wrong.
    `java.lang.CloneNotSupportedException` - never

### clearJavaArgs

    public void clearJavaArgs()

  Clear out the java arguments.

### haveClasspath

    protected boolean haveClasspath()

  Has the classpath been specified and shall it really be used or will build.sysclasspath null it?

  Returns:
    true if the classpath is to be used
  Since:
    Ant 1.6

### haveBootclasspath

    protected boolean haveBootclasspath(boolean log)

  Has the bootclasspath been specified and shall it really be used (build.sysclasspath could be set or the VM may not support it)?

  Parameters:
    `log` - whether to log a warning if a bootclasspath has been specified but will be ignored.
  Returns:
    true if the bootclasspath is to be used
  Since:
    Ant 1.6

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-2005 Apache Software Foundation. All Rights Reserved.