Package org.apache.tools.ant.types
Class CommandlineJava
java.lang.Object
org.apache.tools.ant.types.CommandlineJava
- All Implemented Interfaces:
- Cloneable
A representation of a Java command line that is
 a composite of 2 
Commandlines. One is used for the
 vm/options and one for the classname/arguments. It provides
 specific methods for a Java command line.- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classSpecialized Environment class for System properties.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdd a set of system properties.voidAdd a system property.voidaddSyspropertyset(PropertySet sysp) Add a set of system properties.voidClear out the java arguments.clone()Deep clone the object.Create a new argument to the java program.Create a boot classpath.Create a classpath.Create a modulepath.Create an upgrademodulepath.Create a new JVM argument.Return a String that describes the command and arguments suitable for verbose output before a call toRuntime.exec(String[]).Return a String that describes the java command and arguments for in-VM executions.protected CommandlineGet the VM command parameters, including memory settings.Get the current assertions.Get the boot classpath.Get the name of the class to be run.Get the classpath for the command.String[]Get the command line to run a Java vm.getJar()Get the name of the jar to be run.Get the Java command to be used.Get the name of the module to be run.Get the modulepath.Get the system properties object.Get the upgrademodulepath.Get the VM command, including memory.Get the vm version.protected booleanhaveBootclasspath(boolean log) Determine whether the bootclasspath has been specified, and whether it shall really be used (build.sysclasspath could be set or the VM may not support it).booleanDetermine whether the classpath has been specified, and whether it shall really be used or be nulled by build.sysclasspath.booleanDetermine whether the modulepath has been specified.booleanDetermine whether the upgrademodulepath has been specified.voidRestore the cached system properties.voidsetAssertions(Assertions assertions) Add an assertion set to the command.voidsetClassname(String classname) Set the classname to execute.voidsetCloneVm(boolean cloneVm) Set whether system properties will be copied to the cloned VM--as well as the bootclasspath unless you have explicitly specified a bootclasspath.voidSet a jar file to execute via the -jar option.voidsetMaxmemory(String max) Specify max memory of the JVM.voidSet the module to execute.voidsetSourceFile(String sourceFile) Set the source-file, to execute as single file source programs, a feature, available since Java 11.voidCache current system properties and set them to those in this Java command.voidSet the executable used to start the new JVM.voidsetVmversion(String value) Set the JVM version required.intsize()Deprecated.since 1.7.toString()Get a string description.
- 
Constructor Details- 
CommandlineJavapublic CommandlineJava()Constructor uses the VM we are running on now.
 
- 
- 
Method Details- 
createArgumentCreate a new argument to the java program.- Returns:
- an argument to be configured.
 
- 
createVmArgumentCreate a new JVM argument.- Returns:
- an argument to be configured.
 
- 
addSyspropertyAdd a system property.- Parameters:
- sysp- a property to be set in the JVM.
 
- 
addSyspropertysetAdd a set of system properties.- Parameters:
- sysp- a set of properties.
 
- 
addSyspropertiesAdd a set of system properties.- Parameters:
- sysp- a set of properties.
- Since:
- Ant 1.6.3
 
- 
setVmSet the executable used to start the new JVM.- Parameters:
- vm- the executable to use.
 
- 
setVmversionSet the JVM version required.- Parameters:
- value- the version required.
 
- 
setCloneVmpublic void setCloneVm(boolean cloneVm) Set whether system properties will be copied to the cloned VM--as well as the bootclasspath unless you have explicitly specified a bootclasspath.- Parameters:
- cloneVm- if true copy the system properties.
- Since:
- Ant 1.7
 
- 
getAssertions
- 
setAssertionsAdd an assertion set to the command.- Parameters:
- assertions- assertions to make.
 
- 
setJarSet a jar file to execute via the -jar option.- Parameters:
- jarpathname- the pathname of the jar to execute.
 
- 
getJarGet the name of the jar to be run.- Returns:
- the pathname of the jar file to run via -jar option
 or nullif there is no jar to run.
- See Also:
 
- 
setClassnameSet the classname to execute.- Parameters:
- classname- the fully qualified classname.
 
- 
getClassnameGet the name of the class to be run.- Returns:
- the name of the class to run or nullif there is no class.
- See Also:
 
- 
setSourceFileSet the source-file, to execute as single file source programs, a feature, available since Java 11.- Parameters:
- sourceFile- The path to the source file
- Since:
- Ant 1.10.5
 
- 
getSourceFile- Returns:
- Returns the source-file to execute, if this command line has
 been configured for single file source program execution. Else returns null.
- Since:
- Ant 1.10.5
 
- 
setModuleSet the module to execute.- Parameters:
- module- the module name.
- Since:
- 1.9.7
 
- 
getModuleGet the name of the module to be run.- Returns:
- the name of the module to run or nullif there is no module.
- Since:
- 1.9.7
- See Also:
 
- 
createClasspath
- 
createBootclasspath
- 
createModulepath
- 
createUpgrademodulepath
- 
getVmversion
- 
getCommandlineGet the command line to run a Java vm.- Returns:
- the list of all arguments necessary to run the vm.
 
- 
setMaxmemorySpecify max memory of the JVM. -mx or -Xmx depending on VM version.- Parameters:
- max- the string to pass to the jvm to specify the max memory.
 
- 
toString
- 
describeCommandReturn a String that describes the command and arguments suitable for verbose output before a call toRuntime.exec(String[]).- Returns:
- the description string.
- Since:
- Ant 1.5
 
- 
describeJavaCommandReturn 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
 
- 
getActualVMCommandGet the VM command parameters, including memory settings.- Returns:
- the VM command parameters.
 
- 
sizeDeprecated.since 1.7. Please don't use this, it effectively creates the entire command.Get 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:
 
- 
getJavaCommandGet the Java command to be used.- Returns:
- the java command--not a clone.
 
- 
getVmCommandGet the VM command, including memory.- Returns:
- A deep clone of the instance's VM command, with memory settings added.
 
- 
getClasspath
- 
getBootclasspath
- 
getModulepath
- 
getUpgrademodulepathGet the upgrademodulepath.- Returns:
- upgrademodulepath or null.
- Since:
- 1.9.7
 
- 
setSystemPropertiesCache current system properties and set them to those in this Java command.- Throws:
- BuildException- if Security prevented this operation.
 
- 
restoreSystemPropertiesRestore the cached system properties.- Throws:
- BuildException- if Security prevented this operation, or there was no system properties to restore
 
- 
getSystemPropertiesGet the system properties object.- Returns:
- The system properties object.
 
- 
cloneDeep clone the object.- Overrides:
- clonein class- Object
- Returns:
- a CommandlineJava object.
- Throws:
- BuildException- if anything went wrong.
- CloneNotSupportedException- never.
 
- 
clearJavaArgspublic void clearJavaArgs()Clear out the java arguments.
- 
haveClasspathpublic boolean haveClasspath()Determine whether the classpath has been specified, and whether it shall really be used or be nulled by build.sysclasspath.- Returns:
- true if the classpath is to be used.
- Since:
- Ant 1.6
 
- 
haveBootclasspathprotected boolean haveBootclasspath(boolean log) Determine whether the bootclasspath has been specified, and whether it shall 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
 
- 
haveModulepathpublic boolean haveModulepath()Determine whether the modulepath has been specified.- Returns:
- true if the modulepath is to be used.
- Since:
- 1.9.7
 
- 
haveUpgrademodulepathpublic boolean haveUpgrademodulepath()Determine whether the upgrademodulepath has been specified.- Returns:
- true if the upgrademodulepath is to be used.
- Since:
- 1.9.7
 
 
-