Class JdkUtils


  • public final class JdkUtils
    extends Object
    Set of common JDK utility methods.
    • 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 no tools.jar file on that platform (everything is included in classes.jar).
        Parameters:
        javaHome - The installation directory of the JRE/JDK for which to locate the JDK tools, must not be null.
        Returns:
        The absolute (and possibly non-existent) path to the tools.jar file, never null.
      • 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