Package org.apache.tools.ant.util
Class JavaEnvUtils
- java.lang.Object
- 
- org.apache.tools.ant.util.JavaEnvUtils
 
- 
 public final class JavaEnvUtils extends java.lang.ObjectA set of helper methods related to locating executables or checking conditions of a given Java installation.Starting with Java 10 we've stopped adding JAVA_andVERSION_attributes for new major version numbers of the JVM.- Since:
- Ant 1.5
 
- 
- 
Field SummaryFields Modifier and Type Field Description static java.lang.StringJAVA_1_0Version constant for Java 1.0static java.lang.StringJAVA_1_1Version constant for Java 1.1static java.lang.StringJAVA_1_2Version constant for Java 1.2static java.lang.StringJAVA_1_3Version constant for Java 1.3static java.lang.StringJAVA_1_4Version constant for Java 1.4static java.lang.StringJAVA_1_5Version constant for Java 1.5static java.lang.StringJAVA_1_6Version constant for Java 1.6static java.lang.StringJAVA_1_7Version constant for Java 1.7static java.lang.StringJAVA_1_8Version constant for Java 1.8static java.lang.StringJAVA_1_9Deprecated.use #JAVA_9 insteadstatic java.lang.StringJAVA_10Version constant for Java 10static java.lang.StringJAVA_11Version constant for Java 11static java.lang.StringJAVA_12Version constant for Java 12static java.lang.StringJAVA_9Version constant for Java 9static intVERSION_1_0Number Version constant for Java 1.0static intVERSION_1_1Number Version constant for Java 1.1static intVERSION_1_2Number Version constant for Java 1.2static intVERSION_1_3Number Version constant for Java 1.3static intVERSION_1_4Number Version constant for Java 1.4static intVERSION_1_5Number Version constant for Java 1.5static intVERSION_1_6Number Version constant for Java 1.6static intVERSION_1_7Number Version constant for Java 1.7static intVERSION_1_8Number Version constant for Java 1.8static intVERSION_1_9Deprecated.use #VERSION_9 insteadstatic intVERSION_10Number Version constant for Java 10static intVERSION_11Number Version constant for Java 11static intVERSION_12Number Version constant for Java 12static intVERSION_9Number Version constant for Java 9
 - 
Method SummaryModifier and Type Method Description static java.io.FilecreateVmsJavaOptionFile(java.lang.String[] cmds)Writes the command into a temporary DCL script and returns the corresponding File object.static java.lang.StringgetJavaHome()Return the value of ${java.home}static java.lang.StringgetJavaVersion()Returns the version of Java this class is running under.static intgetJavaVersionNumber()Deprecated.use #getParsedJavaVersion insteadstatic java.lang.StringgetJdkExecutable(java.lang.String command)Finds an executable that is part of a JDK installation based on the java.home system property.static java.lang.StringgetJreExecutable(java.lang.String command)Finds an executable that is part of a JRE installation based on the java.home system property.static java.util.Vector<java.lang.String>getJrePackages()get a vector of strings of packages built into that platforms runtime jar(s)static java.util.Vector<java.lang.String>getJrePackageTestCases()Testing helper method; kept here for unification of changes.static DeweyDecimalgetParsedJavaVersion()Returns the version of Java this class is running under.static booleanisApacheHarmony()Checks whether the current VM is Apache Harmony.static booleanisAtLeastJavaVersion(java.lang.String version)Compares the current Java version to the passed in String - assumes the argument is one of the constants defined in this class.static booleanisClasspathBased()Checks whether the current Java VM is GNU Classpathstatic booleanisGij()Checks whether the current Java VM is the GNU interpreter gij or we are running in a gcj precompiled binary.static booleanisJavaVersion(java.lang.String version)Compares the current Java version to the passed in String - assumes the argument is one of the constants defined in this class.static booleanisKaffe()Checks whether the current Java VM is Kaffe.
 
- 
- 
- 
Field Detail- 
JAVA_1_0public static final java.lang.String JAVA_1_0 Version constant for Java 1.0- See Also:
- Constant Field Values
 
 - 
VERSION_1_0public static final int VERSION_1_0 Number Version constant for Java 1.0- See Also:
- Constant Field Values
 
 - 
JAVA_1_1public static final java.lang.String JAVA_1_1 Version constant for Java 1.1- See Also:
- Constant Field Values
 
 - 
VERSION_1_1public static final int VERSION_1_1 Number Version constant for Java 1.1- See Also:
- Constant Field Values
 
 - 
JAVA_1_2public static final java.lang.String JAVA_1_2 Version constant for Java 1.2- See Also:
- Constant Field Values
 
 - 
VERSION_1_2public static final int VERSION_1_2 Number Version constant for Java 1.2- See Also:
- Constant Field Values
 
 - 
JAVA_1_3public static final java.lang.String JAVA_1_3 Version constant for Java 1.3- See Also:
- Constant Field Values
 
 - 
VERSION_1_3public static final int VERSION_1_3 Number Version constant for Java 1.3- See Also:
- Constant Field Values
 
 - 
JAVA_1_4public static final java.lang.String JAVA_1_4 Version constant for Java 1.4- See Also:
- Constant Field Values
 
 - 
VERSION_1_4public static final int VERSION_1_4 Number Version constant for Java 1.4- See Also:
- Constant Field Values
 
 - 
JAVA_1_5public static final java.lang.String JAVA_1_5 Version constant for Java 1.5- See Also:
- Constant Field Values
 
 - 
VERSION_1_5public static final int VERSION_1_5 Number Version constant for Java 1.5- See Also:
- Constant Field Values
 
 - 
JAVA_1_6public static final java.lang.String JAVA_1_6 Version constant for Java 1.6- See Also:
- Constant Field Values
 
 - 
VERSION_1_6public static final int VERSION_1_6 Number Version constant for Java 1.6- See Also:
- Constant Field Values
 
 - 
JAVA_1_7public static final java.lang.String JAVA_1_7 Version constant for Java 1.7- See Also:
- Constant Field Values
 
 - 
VERSION_1_7public static final int VERSION_1_7 Number Version constant for Java 1.7- See Also:
- Constant Field Values
 
 - 
JAVA_1_8public static final java.lang.String JAVA_1_8 Version constant for Java 1.8- See Also:
- Constant Field Values
 
 - 
VERSION_1_8public static final int VERSION_1_8 Number Version constant for Java 1.8- See Also:
- Constant Field Values
 
 - 
JAVA_1_9@Deprecated public static final java.lang.String JAVA_1_9 Deprecated.use #JAVA_9 insteadVersion constant for Java 1.9- See Also:
- Constant Field Values
 
 - 
VERSION_1_9@Deprecated public static final int VERSION_1_9 Deprecated.use #VERSION_9 insteadNumber Version constant for Java 1.9- See Also:
- Constant Field Values
 
 - 
JAVA_9public static final java.lang.String JAVA_9 Version constant for Java 9- Since:
- Ant 1.9.8
- See Also:
- Constant Field Values
 
 - 
VERSION_9public static final int VERSION_9 Number Version constant for Java 9- Since:
- Ant 1.9.8
- See Also:
- Constant Field Values
 
 - 
JAVA_10public static final java.lang.String JAVA_10 Version constant for Java 10- Since:
- Ant 1.10.7
- See Also:
- Constant Field Values
 
 - 
VERSION_10public static final int VERSION_10 Number Version constant for Java 10- Since:
- Ant 1.10.7
- See Also:
- Constant Field Values
 
 - 
JAVA_11public static final java.lang.String JAVA_11 Version constant for Java 11- Since:
- Ant 1.10.7
- See Also:
- Constant Field Values
 
 - 
VERSION_11public static final int VERSION_11 Number Version constant for Java 11- Since:
- Ant 1.10.7
- See Also:
- Constant Field Values
 
 - 
JAVA_12public static final java.lang.String JAVA_12 Version constant for Java 12- Since:
- Ant 1.10.7
- See Also:
- Constant Field Values
 
 - 
VERSION_12public static final int VERSION_12 Number Version constant for Java 12- Since:
- Ant 1.10.7
- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getJavaVersionpublic static java.lang.String getJavaVersion() Returns the version of Java this class is running under.Up until Java 8 Java version numbers were 1.VERSION - e.g. 1.8.x for Java 8, starting with Java 9 it became 9.x. - Returns:
- the version of Java as a String, e.g. "1.6" or "9"
 
 - 
getJavaVersionNumber@Deprecated public static int getJavaVersionNumber() Deprecated.use #getParsedJavaVersion insteadReturns the version of Java this class is running under.This number can be used for comparisons. - Returns:
- the version of Java as a number 10x the major/minor, e.g Java1.5 has a value of 15 and Java9 the value 90 - major will be 1 for all versions of Java prior to Java 9, minor will be 0 for all versions of Java starting with Java 9.
 
 - 
getParsedJavaVersionpublic static DeweyDecimal getParsedJavaVersion() Returns the version of Java this class is running under.This number can be used for comparisons. - Returns:
- the version of Java as major.minor, e.g Java1.5 has a value of 1.5 and Java9 the value 9 - major will be 1 for all versions of Java prior to Java 9, minor will be 0 for all versions of Java starting with Java 9.
 
 - 
isJavaVersionpublic static boolean isJavaVersion(java.lang.String version) Compares the current Java version to the passed in String - assumes the argument is one of the constants defined in this class. Note that Ant now requires JDK 1.8+ soJAVA_1_0throughJAVA_1_7need no longer be tested for.- Parameters:
- version- the version to check against the current version.
- Returns:
- true if the version of Java is the same as the given version.
- Since:
- Ant 1.5
 
 - 
isAtLeastJavaVersionpublic static boolean isAtLeastJavaVersion(java.lang.String version) Compares the current Java version to the passed in String - assumes the argument is one of the constants defined in this class. Note that Ant now requires JDK 1.8+ soJAVA_1_0throughJAVA_1_7need no longer be tested for.- Parameters:
- version- the version to check against the current version.
- Returns:
- true if the version of Java is the same or higher than the given version.
- Since:
- Ant 1.7
 
 - 
isKaffepublic static boolean isKaffe() Checks whether the current Java VM is Kaffe.- Returns:
- true if the current Java VM is Kaffe.
- Since:
- Ant 1.6.3
- See Also:
- https://github.com/kaffe/kaffe
 
 - 
isClasspathBasedpublic static boolean isClasspathBased() Checks whether the current Java VM is GNU Classpath- Returns:
- true if the version of Java is GNU Classpath
- Since:
- Ant 1.9.1
 
 - 
isGijpublic static boolean isGij() Checks whether the current Java VM is the GNU interpreter gij or we are running in a gcj precompiled binary.- Returns:
- true if the current Java VM is gcj/gij.
- Since:
- Ant 1.8.2
 
 - 
isApacheHarmonypublic static boolean isApacheHarmony() Checks whether the current VM is Apache Harmony.- Returns:
- true if the current VM is Apache Harmony.
- Since:
- Ant 1.8.2
 
 - 
getJreExecutablepublic static java.lang.String getJreExecutable(java.lang.String command) Finds an executable that is part of a JRE installation based on the java.home system property.java,keytool,policytool,orbd,rmid,rmiregistry,servertoolandtnameservare JRE executables on Sun based JRE's.You typically find them in JAVA_HOME/jre/binifJAVA_HOMEpoints to your JDK installation. JDK < 1.2 has them in the same directory as the JDK executables.- Parameters:
- command- the java executable to find.
- Returns:
- the path to the command.
- Since:
- Ant 1.5
 
 - 
getJdkExecutablepublic static java.lang.String getJdkExecutable(java.lang.String command) Finds an executable that is part of a JDK installation based on the java.home system property.You typically find them in JAVA_HOME/binifJAVA_HOMEpoints to your JDK installation.- Parameters:
- command- the java executable to find.
- Returns:
- the path to the command.
- Since:
- Ant 1.5
 
 - 
getJrePackageTestCasespublic static java.util.Vector<java.lang.String> getJrePackageTestCases() Testing helper method; kept here for unification of changes.- Returns:
- a list of test classes depending on the java version.
 
 - 
getJrePackagespublic static java.util.Vector<java.lang.String> getJrePackages() get a vector of strings of packages built into that platforms runtime jar(s)- Returns:
- list of packages.
 
 - 
createVmsJavaOptionFilepublic static java.io.File createVmsJavaOptionFile(java.lang.String[] cmds) throws java.io.IOExceptionWrites the command into a temporary DCL script and returns the corresponding File object. It is the job of the caller to delete the file on exit.- Parameters:
- cmds- the command.
- Returns:
- the file containing the command.
- Throws:
- java.io.IOException- if there is an error writing to the file.
 
 - 
getJavaHomepublic static java.lang.String getJavaHome() Return the value of ${java.home}- Returns:
- the java home value.
 
 
- 
 
-