Class JdkUtils
- java.lang.Object
-
- org.codehaus.cargo.container.internal.util.JdkUtils
-
public final class JdkUtils extends Object
Set of common JDK utility methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
getMajorJavaVersion()
Get the major Java version.static File
getToolsJar()
Returns the file containing the JDK tools (such as the compiler).static File
getToolsJar(String javaHome)
Returns the file containing the JDK tools (such as the compiler) for the specified Java installation.static boolean
isOSX()
Is the user running on a Macintosh OS X system?static boolean
isWindows()
Is the user running on a Windows system?static int
parseMajorJavaVersion(String version)
Parse major Java version from a Java version string.static void
sleep(long ms)
Pauses the current thread for the specified amount.
-
-
-
Method Detail
-
getToolsJar
public static File getToolsJar() throws FileNotFoundException
Returns the file containing the JDK tools (such as the compiler). This method must not be called on Mac OSX as there is no tools.jar file on that platform (everything is included in classes.jar).- Returns:
- The tools.jar file
- Throws:
FileNotFoundException
- If the tools.jar file could not be found
-
getToolsJar
public static File getToolsJar(String javaHome)
Returns the file containing the JDK tools (such as the compiler) for the specified Java installation. This method must not be called on Mac OSX as there is notools.jar
file on that platform (everything is included inclasses.jar
).- Parameters:
javaHome
- The installation directory of the JRE/JDK for which to locate the JDK tools, must not benull
.- Returns:
- The absolute (and possibly non-existent) path to the
tools.jar
file, nevernull
.
-
isOSX
public static boolean isOSX()
Is the user running on a Macintosh OS X system? Heuristic derived from Apple Tech Note 2042.- Returns:
- true if the user's system is determined to be Mac OS X.
-
isWindows
public static boolean isWindows()
Is the user running on a Windows system?- Returns:
- true if the user's system is determined to be Windows.
-
getMajorJavaVersion
public static int getMajorJavaVersion()
Get the major Java version.- Returns:
- Major Java version.
-
parseMajorJavaVersion
public static int parseMajorJavaVersion(String version)
Parse major Java version from a Java version string.- Parameters:
version
- Java version string.- Returns:
- Major Java version.
-
sleep
public static void sleep(long ms)
Pauses the current thread for the specified amount.- Parameters:
ms
- The time to sleep in milliseconds
-
-