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
conditons of a given Java installation.
static String | JAVA_1_0 - Version constant for Java 1.0
|
static String | JAVA_1_1 - Version constant for Java 1.1
|
static String | JAVA_1_2 - Version constant for Java 1.2
|
static String | JAVA_1_3 - Version constant for Java 1.3
|
static String | JAVA_1_4 - Version constant for Java 1.4
|
static String | JAVA_1_5 - Version constant for Java 1.5
|
static String | JAVA_1_6 - Version constant for Java 1.6
|
static File | createVmsJavaOptionFile(String[] cmd) -
Writes the command into a temporary DCL script and returns the
corresponding File object.
|
static String | getJavaHome() - Return the value of ${java.home}
|
static 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 String | getJdkExecutable(String command) - Finds an executable that is part of a JDK installation based on
the java.home system property.
|
static String | getJreExecutable(String command) - Finds an executable that is part of a JRE installation based on
the java.home system property.
|
static Vector | getJrePackageTestCases() - Testing helper method; kept here for unification of changes.
|
static Vector | getJrePackages() - get a vector of strings of packages built into
that platforms runtime jar(s)
|
static boolean | isAtLeastJavaVersion(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()
|
static boolean | isJavaVersion(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.
|
JAVA_1_0
public static final String JAVA_1_0
Version constant for Java 1.0
JAVA_1_1
public static final String JAVA_1_1
Version constant for Java 1.1
JAVA_1_2
public static final String JAVA_1_2
Version constant for Java 1.2
JAVA_1_3
public static final String JAVA_1_3
Version constant for Java 1.3
JAVA_1_4
public static final String JAVA_1_4
Version constant for Java 1.4
JAVA_1_5
public static final String JAVA_1_5
Version constant for Java 1.5
JAVA_1_6
public static final String JAVA_1_6
Version constant for Java 1.6
createVmsJavaOptionFile
public static File createVmsJavaOptionFile(String[] cmd)
throws 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.
- the file containing the command.
getJavaHome
public static String getJavaHome()
Return the value of ${java.home}
getJavaVersion
public static String getJavaVersion()
Returns the version of Java this class is running under.
- the version of Java as a String, e.g. "1.1"
getJavaVersionNumber
public static int getJavaVersionNumber()
Returns the version of Java this class is running under.
This number can be used for comparisions; it will always be
- the version of Java as a number 10x the major/minor,
e.g Java1.5 has a value of 15
getJdkExecutable
public static String getJdkExecutable(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.
command
- the java executable to find.
getJreExecutable
public static String getJreExecutable(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.
command
- the java executable to find.
getJrePackageTestCases
public static Vector getJrePackageTestCases()
Testing helper method; kept here for unification of changes.
- a list of test classes depending on the java version.
getJrePackages
public static Vector getJrePackages()
get a vector of strings of packages built into
that platforms runtime jar(s)
isAtLeastJavaVersion
public static boolean isAtLeastJavaVersion(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.2+ so
JAVA_1_0
and
JAVA_1_1
need no longer be tested for.
version
- the version to check against the current version.
- true if the version of Java is the same or higher than the
given version.
isClasspathBased
public static boolean isClasspathBased()
isJavaVersion
public static boolean isJavaVersion(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.2+ so
JAVA_1_0
and
JAVA_1_1
need no longer be tested for.
version
- the version to check against the current version.
- true if the version of Java is the same as the given version.
isKaffe
public static boolean isKaffe()
Checks whether the current Java VM is Kaffe.
- true if the current Java VM is Kaffe.