JavaEnvUtils (Apache Ant API)
Date: 2016-04-09

org.apache.tools.ant.util

## Class JavaEnvUtils

- java.lang.Object
- - org.apache.tools.ant.util.JavaEnvUtils

-     public final class JavaEnvUtils
      extends java.lang.Object

  A set of helper methods related to locating executables or checking conditions of a given Java installation.
  Since:
    Ant 1.5

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `JAVA_1_0` Version constant for Java 1.0
    `static java.lang.String` | `JAVA_1_1` Version constant for Java 1.1
    `static java.lang.String` | `JAVA_1_2` Version constant for Java 1.2
    `static java.lang.String` | `JAVA_1_3` Version constant for Java 1.3
    `static java.lang.String` | `JAVA_1_4` Version constant for Java 1.4
    `static java.lang.String` | `JAVA_1_5` Version constant for Java 1.5
    `static java.lang.String` | `JAVA_1_6` Version constant for Java 1.6
    `static java.lang.String` | `JAVA_1_7` Version constant for Java 1.7
    `static java.lang.String` | `JAVA_1_8` Version constant for Java 1.8
    `static java.lang.String` | `JAVA_1_9` Version constant for Java 1.9
    `static int` | `VERSION_1_0` Number Version constant for Java 1.0
    `static int` | `VERSION_1_1` Number Version constant for Java 1.1
    `static int` | `VERSION_1_2` Number Version constant for Java 1.2
    `static int` | `VERSION_1_3` Number Version constant for Java 1.3
    `static int` | `VERSION_1_4` Number Version constant for Java 1.4
    `static int` | `VERSION_1_5` Number Version constant for Java 1.5
    `static int` | `VERSION_1_6` Number Version constant for Java 1.6
    `static int` | `VERSION_1_7` Number Version constant for Java 1.7
    `static int` | `VERSION_1_8` Number Version constant for Java 1.8
    `static int` | `VERSION_1_9` Number Version constant for Java 1.9

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.io.File` | `createVmsJavaOptionFile(java.lang.String[] cmd)` Writes the command into a temporary DCL script and returns the corresponding File object.
    `static java.lang.String` | `getJavaHome()` Return the value of ${java.home}
    `static java.lang.String` | `getJavaVersion()` Returns the version of Java this class is running under.
    `static int` | `getJavaVersionNumber()` Returns the version of Java this class is running under.
    `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.
    `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.
    `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 boolean` | `isApacheHarmony()` Checks whether the current VM is Apache Harmony.
    `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.
    `static boolean` | `isClasspathBased()` Checks whether the current Java VM is GNU Classpath
    `static boolean` | `isGij()` Checks whether the current Java VM is the GNU interpreter gij or we are running in a gcj precompiled binary.
    `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.
    `static boolean` | `isKaffe()` Checks whether the current Java VM is Kaffe.

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

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

- - ### Field Detail

    - #### JAVA_1_0

          public static final java.lang.String JAVA_1_0

      Version constant for Java 1.0
      See Also:
        Constant Field Values

    - #### VERSION_1_0

          public static final int VERSION_1_0

      Number Version constant for Java 1.0
      See Also:
        Constant Field Values

    - #### JAVA_1_1

          public static final java.lang.String JAVA_1_1

      Version constant for Java 1.1
      See Also:
        Constant Field Values

    - #### VERSION_1_1

          public static final int VERSION_1_1

      Number Version constant for Java 1.1
      See Also:
        Constant Field Values

    - #### JAVA_1_2

          public static final java.lang.String JAVA_1_2

      Version constant for Java 1.2
      See Also:
        Constant Field Values

    - #### VERSION_1_2

          public static final int VERSION_1_2

      Number Version constant for Java 1.2
      See Also:
        Constant Field Values

    - #### JAVA_1_3

          public static final java.lang.String JAVA_1_3

      Version constant for Java 1.3
      See Also:
        Constant Field Values

    - #### VERSION_1_3

          public static final int VERSION_1_3

      Number Version constant for Java 1.3
      See Also:
        Constant Field Values

    - #### JAVA_1_4

          public static final java.lang.String JAVA_1_4

      Version constant for Java 1.4
      See Also:
        Constant Field Values

    - #### VERSION_1_4

          public static final int VERSION_1_4

      Number Version constant for Java 1.4
      See Also:
        Constant Field Values

    - #### JAVA_1_5

          public static final java.lang.String JAVA_1_5

      Version constant for Java 1.5
      See Also:
        Constant Field Values

    - #### VERSION_1_5

          public static final int VERSION_1_5

      Number Version constant for Java 1.5
      See Also:
        Constant Field Values

    - #### JAVA_1_6

          public static final java.lang.String JAVA_1_6

      Version constant for Java 1.6
      See Also:
        Constant Field Values

    - #### VERSION_1_6

          public static final int VERSION_1_6

      Number Version constant for Java 1.6
      See Also:
        Constant Field Values

    - #### JAVA_1_7

          public static final java.lang.String JAVA_1_7

      Version constant for Java 1.7
      See Also:
        Constant Field Values

    - #### VERSION_1_7

          public static final int VERSION_1_7

      Number Version constant for Java 1.7
      See Also:
        Constant Field Values

    - #### JAVA_1_8

          public static final java.lang.String JAVA_1_8

      Version constant for Java 1.8
      See Also:
        Constant Field Values

    - #### VERSION_1_8

          public static final int VERSION_1_8

      Number Version constant for Java 1.8
      See Also:
        Constant Field Values

    - #### JAVA_1_9

          public static final java.lang.String JAVA_1_9

      Version constant for Java 1.9
      See Also:
        Constant Field Values

    - #### VERSION_1_9

          public static final int VERSION_1_9

      Number Version constant for Java 1.9
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getJavaVersion

          public static java.lang.String getJavaVersion()

      Returns the version of Java this class is running under.
      Returns:
        the version of Java as a String, e.g. "1.6"

    - #### getJavaVersionNumber

          public static int getJavaVersionNumber()

      Returns the version of Java this class is running under. This number can be used for comparisons; it will always be
      Returns:
        the version of Java as a number 10x the major/minor, e.g Java1.5 has a value of 15

    - #### isJavaVersion

          public 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.5+ so `JAVA_1_0` through `JAVA_1_4` need 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

    - #### isAtLeastJavaVersion

          public 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.5+ so `JAVA_1_0` through `JAVA_1_4` need 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

    - #### isKaffe

          public 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:
        http://www.kaffe.org/

    - #### isClasspathBased

          public 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

    - #### isGij

          public 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

    - #### isApacheHarmony

          public 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

    - #### getJreExecutable

          public 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`, `servertool` and `tnameserv` are JRE executables on Sun based JRE's.

      You typically find them in `JAVA_HOME/jre/bin` if `JAVA_HOME` points 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

    - #### getJdkExecutable

          public 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/bin` if `JAVA_HOME` points to your JDK installation.

      Parameters:
        `command` - the java executable to find.
      Returns:
        the path to the command.
      Since:
        Ant 1.5

    - #### getJrePackageTestCases

          public 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.

    - #### getJrePackages

          public 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.

    - #### createVmsJavaOptionFile

          public static java.io.File createVmsJavaOptionFile(java.lang.String[] cmd)
                                                      throws java.io.IOException

      Writes 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:
        `cmd` - the command.
      Returns:
        the file containing the command.
      Throws:
        `java.io.IOException` - if there is an error writing to the file.

    - #### getJavaHome

          public static java.lang.String getJavaHome()

      Return the value of ${java.home}
      Returns:
        the java home value.