com.gridsystems.utils
Class JavaVersion

java.lang.Object
  extended by com.gridsystems.utils.Version
      extended by com.gridsystems.utils.JavaVersion
All Implemented Interfaces:
java.lang.Comparable<Version>

public class JavaVersion
extends Version

Class used to store and manage the versions of the JRE.

Author:
SJM

Constructor Summary
JavaVersion(java.lang.String javaVersion)
          Constructor.
 
Method Summary
static boolean checkJavaHome()
          Convenience method for verifying JAVA_HOME environment variable.
static boolean checkJavaVersion(java.lang.String versionPrefix)
          Convenience method for verifying Java runtime version.
static JavaVersion getCurrentVersion()
          Gets the JavaVersion object associated with the current version of JRE.
static java.lang.String getJavaHome()
          Gets the the value that the JAVA_HOME variable must have.
static boolean isJdkRunning()
          Checks if the value from getJavaHome() points to a JRE or JDK.
 
Methods inherited from class com.gridsystems.utils.Version
compareTo, equals, getDoubleRepresentation, getMajorVersion, getMinorVersion, getRelease, getSize, getStringRepresentation, getStringRepresentation, getValue, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaVersion

public JavaVersion(java.lang.String javaVersion)
Constructor.

Parameters:
javaVersion - the String from which the java information is obtained. It is interpreted as an arbitrarily long series of integers separated by non-digit characters.
Method Detail

getCurrentVersion

public static JavaVersion getCurrentVersion()
Gets the JavaVersion object associated with the current version of JRE.

Returns:
the JavaVersion associated to the version of the current JRE.

checkJavaHome

public static boolean checkJavaHome()
Convenience method for verifying JAVA_HOME environment variable.

Returns:
true if JAVA_HOME is correctly set, false otherwise

checkJavaVersion

public static boolean checkJavaVersion(java.lang.String versionPrefix)
Convenience method for verifying Java runtime version.

Parameters:
versionPrefix - prefix for java version e.g. "1.3", "1.4", "1.4.2", etc.
Returns:
true if version is equal or higher, false otherwise

getJavaHome

public static java.lang.String getJavaHome()
Gets the the value that the JAVA_HOME variable must have.

Returns:
a String with the proper value for the JAVA_HOME variable. This is obtained using the "java.home" system property and guessing if it is the JDK or the JRE that is installed.

isJdkRunning

public static boolean isJdkRunning()
Checks if the value from getJavaHome() points to a JRE or JDK.

Returns:
a boolean that is true if and only if the result from getJavaHome() points to a JDK instead of a JRE.


Copyright © 2007-2008 Grid Systems, S.A.. All Rights Reserved.