Class SystemInfo


  • public final class SystemInfo
    extends java.lang.Object
    A utility class can detect OS system information.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  SystemInfo.JavaVersion  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getCurrentDirectory()
      Returns the user's home directory.
      static int getDisplayScale()  
      static java.lang.String getJavaClassVersion()
      Returns the version of the java class we're using.
      static java.lang.String getJavaVendor()
      Returns the vendor for java we're using.
      static java.lang.String getJavaVersion()
      Returns the version of java we're using.
      static java.lang.String getOS()
      Returns the operating system.
      static java.lang.String getOSArchitecture()
      Returns the operating system architecture.
      static java.lang.String getOSVersion()
      Returns the operating system version.
      static boolean isAnyMac()
      Returns whether or not the os is any Mac os.
      static boolean isBSD()
      Returns whether or not the os is *BSD.
      static boolean isCJKLocale()
      Returns whether the default locale is one of the three language - Chinese, Japanese or Korean - also known as CJK.
      static boolean isCJKLocale​(java.util.Locale locale)
      Returns whether the locale is one of the three language - Chinese, Japanese or Korean - also known as CJK.
      static boolean isClassicWindows()
      Gets the state of the flag which indicates if the old Windows look and feel should be rendered.
      static boolean isJdk13Above()
      Returns whether or no the JDK version is 1.3 and above.
      static boolean isJdk142Above()
      Returns whether or no the JDK version is 1.4.2 and above.
      static boolean isJdk14Above()
      Returns whether or no the JDK version is 1.4 and above.
      static boolean isJdk15Above()
      Returns whether or no the JDK version is 1.5 and above.
      static boolean isJdk6Above()
      Returns whether or no the JDK version is 6 and above.
      static boolean isJdk6u10Above()
      Returns whether or no the JDK version is 6u10 and above.
      static boolean isJdk6u14Above()
      Returns whether or no the JDK version is 6u14 and above.
      static boolean isJdk6u25Above()
      Returns whether or no the JDK version is 6u25 and above.
      static boolean isJdk7Above()
      Returns whether or no the JDK version is 1.7 and above.
      static boolean isJdk7u40Above()
      Returns whether or no the JDK version is 1.7u40 and above.
      static boolean isJdk8Above()
      Returns whether or no the JDK version is 1.8 and above.
      static boolean isJdk9Above()
      Returns whether or no the JDK version is 1.9 and above.
      static boolean isJdkVersion​(double majorVersion, int minorVersion, int build)
      Returns whether or not the JDK version is exactly the version you are expecting
      static boolean isJdkVersionAbove​(double majorVersion, int minorVersion, int build)
      Returns whether or not the JDK version is above the version, including the version, you are expecting
      static boolean isJdkVersionBelow​(double majorVersion, int minorVersion, int build)
      Returns whether or not the JDK version is below the version, including the version, you are expecting
      static boolean isLinux()
      Returns whether or not the os is Linux.
      static boolean isMacClassic()
      Returns whether or not the os is Mac 9.1 or earlier.
      static boolean isMacOSX()
      Returns whether or not the os is Mac OSX.
      static boolean isMnemonicHidden()
      Gets the state of the hide mnemonic flag.
      static boolean isSolaris()
      Returns whether or not the os is Solaris.
      static boolean isUnix()
      Returns whether or not the os is some version of Unix, defined here as only Solaris, Linux or *BSD.
      static boolean isWindows()
      Returns whether or not the os is some version of Windows.
      static boolean isWindows2003()
      Returns whether or not the os is some version of Windows 2003.
      static boolean isWindows7()
      Returns whether or not the os is some version of Windows 7.
      static boolean isWindows8()
      Returns whether or not the os is some version of Windows 8.
      static boolean isWindows95()
      Returns whether or not the os is some version of Windows 95.
      static boolean isWindows98()
      Returns whether or not the os is some version of Windows 98.
      static boolean isWindowsNTor2000()
      Returns whether or not the os is some version of Windows NT.
      static boolean isWindowsVista()
      Returns whether or not the os is some version of Windows Vista.
      static boolean isWindowsVistaAbove()
      Returns whether or not the os is some version of Windows Vista or Windows 7.
      static boolean isWindowsXP()
      Returns whether or not the os is some version of Windows XP.
      static void setSupportsTray​(boolean support)
      Set supportTray to false in case dll is missing.
      static boolean supportsTray()
      Returns true if this is Windows NT or Windows 2000 and hence can support a system tray feature.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getJavaVersion

        public static java.lang.String getJavaVersion()
        Returns the version of java we're using.
        Returns:
        the java version.
      • getJavaVendor

        public static java.lang.String getJavaVendor()
        Returns the vendor for java we're using.
        Returns:
        the java vendor.
      • getJavaClassVersion

        public static java.lang.String getJavaClassVersion()
        Returns the version of the java class we're using.
        Returns:
        the java class version.
      • getOS

        public static java.lang.String getOS()
        Returns the operating system.
        Returns:
        the os name.
      • getOSVersion

        public static java.lang.String getOSVersion()
        Returns the operating system version.
        Returns:
        the os version.
      • getOSArchitecture

        public static java.lang.String getOSArchitecture()
        Returns the operating system architecture.
        Returns:
        the os architecture.
      • getCurrentDirectory

        public static java.lang.String getCurrentDirectory()
        Returns the user's home directory.
        Returns:
        the user home .
      • supportsTray

        public static boolean supportsTray()
        Returns true if this is Windows NT or Windows 2000 and hence can support a system tray feature.
        Returns:
        true of system tray is supported.
      • setSupportsTray

        public static void setSupportsTray​(boolean support)
        Set supportTray to false in case dll is missing.
        Parameters:
        support - true or false.
      • isWindows

        public static boolean isWindows()
        Returns whether or not the os is some version of Windows.
        Returns:
        true if the application is running on some Windows version, false otherwise.
      • isClassicWindows

        public static boolean isClassicWindows()
        Gets the state of the flag which indicates if the old Windows look and feel should be rendered. This flag is used by the component UI delegates as a hint to determine which style the component should be rendered.
        Returns:
        true if Windows 95 and Windows NT 4 look and feel should be rendered.
      • isWindowsNTor2000

        public static boolean isWindowsNTor2000()
        Returns whether or not the os is some version of Windows NT.
        Returns:
        true if the application is running on Windows NT or 2000, false otherwise.
      • isWindowsXP

        public static boolean isWindowsXP()
        Returns whether or not the os is some version of Windows XP.
        Returns:
        true if the application is running on Windows XP, false otherwise.
      • isWindowsVista

        public static boolean isWindowsVista()
        Returns whether or not the os is some version of Windows Vista.
        Returns:
        true if the application is running on Windows Vista, false otherwise.
      • isWindows7

        public static boolean isWindows7()
        Returns whether or not the os is some version of Windows 7.
        Returns:
        true if the application is running on Windows 7, false otherwise.
      • isWindows8

        public static boolean isWindows8()
        Returns whether or not the os is some version of Windows 8.
        Returns:
        true if the application is running on Windows 8, false otherwise.
        Since:
        3.4.9
      • isWindowsVistaAbove

        public static boolean isWindowsVistaAbove()
        Returns whether or not the os is some version of Windows Vista or Windows 7.
        Returns:
        true if the application is running on Windows Vista or Windows 7, false otherwise.
      • isWindows95

        public static boolean isWindows95()
        Returns whether or not the os is some version of Windows 95.
        Returns:
        true if the application is running on Windows XP, false otherwise.
      • isWindows98

        public static boolean isWindows98()
        Returns whether or not the os is some version of Windows 98.
        Returns:
        true if the application is running on Windows XP, false otherwise.
      • isWindows2003

        public static boolean isWindows2003()
        Returns whether or not the os is some version of Windows 2003.
        Returns:
        true if the application is running on Windows 2003, false otherwise.
      • isMacClassic

        public static boolean isMacClassic()
        Returns whether or not the os is Mac 9.1 or earlier.
        Returns:
        true if the application is running on a Mac version prior to OSX, false otherwise.
      • isMacOSX

        public static boolean isMacOSX()
        Returns whether or not the os is Mac OSX.
        Returns:
        true if the application is running on Mac OSX, false otherwise.
      • isAnyMac

        public static boolean isAnyMac()
        Returns whether or not the os is any Mac os.
        Returns:
        true if the application is running on Mac OSX or any previous mac version, false otherwise.
      • isSolaris

        public static boolean isSolaris()
        Returns whether or not the os is Solaris.
        Returns:
        true if the application is running on Solaris, false otherwise.
      • isLinux

        public static boolean isLinux()
        Returns whether or not the os is Linux.
        Returns:
        true if the application is running on Linux, false otherwise.
      • isBSD

        public static boolean isBSD()
        Returns whether or not the os is *BSD.
        Returns:
        true if the application is running on *BSD, false otherwise.
      • isUnix

        public static boolean isUnix()
        Returns whether or not the os is some version of Unix, defined here as only Solaris, Linux or *BSD.
        Returns:
        true if the application is running on a type of UNIX such as Linux, Solaris or *BSD, false otherwise.
      • isJdk13Above

        public static boolean isJdk13Above()
        Returns whether or no the JDK version is 1.3 and above.
        Returns:
        true if the application is running on JDK 1.3 and above, false otherwise.
      • isJdk142Above

        public static boolean isJdk142Above()
        Returns whether or no the JDK version is 1.4.2 and above.
        Returns:
        true if the application is running on JDK 1.4.2 and above, false otherwise.
      • isJdk14Above

        public static boolean isJdk14Above()
        Returns whether or no the JDK version is 1.4 and above.
        Returns:
        true if the application is running on JDK 1.4 and above, false otherwise.
      • isJdk15Above

        public static boolean isJdk15Above()
        Returns whether or no the JDK version is 1.5 and above.
        Returns:
        true if the application is running on JDK 1.5 and above, false otherwise.
      • isJdk6Above

        public static boolean isJdk6Above()
        Returns whether or no the JDK version is 6 and above.
        Returns:
        true if the application is running on JDK 6 and above, false otherwise.
      • isJdk6u10Above

        public static boolean isJdk6u10Above()
        Returns whether or no the JDK version is 6u10 and above.
        Returns:
        true if the application is running on JDK 6u10 and above, false otherwise.
      • isJdk6u14Above

        public static boolean isJdk6u14Above()
        Returns whether or no the JDK version is 6u14 and above. There are some heavyweight component and lightweight component mixing changes in JDK6u14.
        Returns:
        true if the application is running on JDK 6u14 and above, false otherwise.
      • isJdk6u25Above

        public static boolean isJdk6u25Above()
        Returns whether or no the JDK version is 6u25 and above. Event firing for JComboBox changes in JDK6u25.
        Returns:
        true if the application is running on JDK 6u25 and above, false otherwise.
      • isJdk7Above

        public static boolean isJdk7Above()
        Returns whether or no the JDK version is 1.7 and above.
        Returns:
        true if the application is running on JDK 1.7 and above, false otherwise.
      • isJdk7u40Above

        public static boolean isJdk7u40Above()
        Returns whether or no the JDK version is 1.7u40 and above.
        Returns:
        true if the application is running on JDK 1.7u40 and above, false otherwise.
      • isJdk8Above

        public static boolean isJdk8Above()
        Returns whether or no the JDK version is 1.8 and above.
        Returns:
        true if the application is running on JDK 1.8 and above, false otherwise.
        Since:
        3.4.9
      • isJdk9Above

        public static boolean isJdk9Above()
        Returns whether or no the JDK version is 1.9 and above.
        Returns:
        true if the application is running on JDK 1.9 and above, false otherwise.
        Since:
        4.0
      • isJdkVersion

        public static boolean isJdkVersion​(double majorVersion,
                                           int minorVersion,
                                           int build)
        Returns whether or not the JDK version is exactly the version you are expecting
        Parameters:
        majorVersion - your intended major version for JDK6u10, it should be 1.6
        minorVersion - your intended major version for JDK6u10, it should be 0
        build - your intended major version for JDK6u10, it should be 10
        Returns:
        true if the application is running on the input version, false otherwise.
      • isJdkVersionAbove

        public static boolean isJdkVersionAbove​(double majorVersion,
                                                int minorVersion,
                                                int build)
        Returns whether or not the JDK version is above the version, including the version, you are expecting
        Parameters:
        majorVersion - your intended major version for JDK6u10, it should be 1.6
        minorVersion - your intended major version for JDK6u10, it should be 0
        build - your intended major version for JDK6u10, it should be 10
        Returns:
        true if the application is running on the input version, false otherwise.
      • isJdkVersionBelow

        public static boolean isJdkVersionBelow​(double majorVersion,
                                                int minorVersion,
                                                int build)
        Returns whether or not the JDK version is below the version, including the version, you are expecting
        Parameters:
        majorVersion - your intended major version for JDK6u10, it should be 1.6
        minorVersion - your intended major version for JDK6u10, it should be 0
        build - your intended major version for JDK6u10, it should be 10
        Returns:
        true if the application is running on the input version, false otherwise.
      • isCJKLocale

        public static boolean isCJKLocale()
        Returns whether the default locale is one of the three language - Chinese, Japanese or Korean - also known as CJK.
        Returns:
        true if the default locale is in CJK.
      • isCJKLocale

        public static boolean isCJKLocale​(java.util.Locale locale)
        Returns whether the locale is one of the three language - Chinese, Japanese or Korean - also known as CJK.
        Parameters:
        locale - the locale to be checked.
        Returns:
        true if the default locale is in CJK.
      • getDisplayScale

        public static int getDisplayScale()
      • isMnemonicHidden

        public static boolean isMnemonicHidden()
        Gets the state of the hide mnemonic flag. This only has meaning if this feature is supported by the underlying OS.
        Returns:
        true if mnemonics are hidden, otherwise, false
        Since:
        3.7.2