Class SystemUtil

java.lang.Object
alpine.common.util.SystemUtil

public final class SystemUtil extends Object
This class contains a collection of commonly used static methods which reveal system-wide information. These provide no security-related fixes to any issue, and are merely available as a convenience.
Since:
1.0
Author:
Steve Springett
  • Method Details

    • isWindows

      public static boolean isWindows()
      Return true if the host operating system is Windows. Given the currently-supported set of platforms, if this returns false, the OS must be some flavor of UNIX.
      Returns:
      True if Windows, False if not
      Since:
      1.0
    • isMac

      public static boolean isMac()
      Return true if the host operating system is OS X.
      Returns:
      True if OS X, False if not
      Since:
      1.0
    • isLinux

      public static boolean isLinux()
      Return true if the host operating system is Linux.
      Returns:
      True if Linux, False if not
      Since:
      1.0
    • isUnix

      public static boolean isUnix()
      Return true if the host operating system is Unix/Linux. This includes all OS's (except for Mac) which fall in this category.
      Returns:
      True if Unix, False if not
      Since:
      1.0
    • isSolaris

      public static boolean isSolaris()
      Return true if the host operating system is SunOS/Solaris.
      Returns:
      True if Solaris, False if not
      Since:
      1.0
    • getLineEnder

      public static String getLineEnder()
      Return the correct line ender for the host operating system, e.g. \r\n for Windows, \n for UNIX.
      Returns:
      String containing the line ender for the host operating system
      Since:
      1.0
    • is32Bit

      public static boolean is32Bit()
      Return true if the OS architecture model is 32bit.
      Returns:
      True if 32bit, False if not
      Since:
      1.0
    • is64Bit

      public static boolean is64Bit()
      Return true if the OS architecture model is 64bit.
      Returns:
      True if 64bit, False if not
      Since:
      1.0
    • getOsName

      public static String getOsName()
      Return the name of the host operating system.
      Returns:
      String containing the name of the host operating system
      Since:
      1.0
    • getOsArchitecture

      public static String getOsArchitecture()
      Return the OS architecture.
      Returns:
      String containing the OS architecture
      Since:
      1.0
    • getOsVersion

      public static String getOsVersion()
      Return the OS version.
      Returns:
      String containing the OS version
      Since:
      1.0
    • getFileSeparator

      public static String getFileSeparator()
      Return the file separator character that separates components of a file path. This is "/" on UNIX and "\" on Windows.
      Returns:
      String containing the file separator character
      Since:
      1.0
    • getPathSeparator

      public static String getPathSeparator()
      Return the path separator character used in java.class.path.
      Returns:
      String containing the path separator character
      Since:
      1.0
    • getUserName

      public static String getUserName()
      Return the username that is executing the current running Java process.
      Returns:
      String containing the username that is executing the current running Java process
      Since:
      1.0
    • getUserHome

      public static String getUserHome()
      Return the home directory of the user executing the current running Java process.
      Returns:
      String containing the home directory of the user executing the current running Java process
      Since:
      1.0
    • getJavaVendor

      public static String getJavaVendor()
      Return the Java vendor.
      Returns:
      String containing the Java vendor
      Since:
      1.0
    • getJavaVersion

      public static Runtime.Version getJavaVersion()
      Return the Java version.
      Returns:
      JavaVersion containing Java version information
      Since:
      1.0
    • getJavaHome

      public static String getJavaHome()
      Return the JAVA_HOME environment variable.
      Returns:
      String containing the JAVA_HOME environment variable
      Since:
      1.0
    • getJavaTempDir

      public static String getJavaTempDir()
      Return the temporary directory to be used by Java.
      Returns:
      String containing the temporary directory to be used by Java
      Since:
      1.0
    • getClassPath

      public static String getClassPath()
      Return the classpath.
      Returns:
      String containing the classpath
      Since:
      1.0
    • getLibraryPath

      public static String getLibraryPath()
      Return the library path.
      Returns:
      String containing the library path
      Since:
      1.0
    • getBitBucket

      public static String getBitBucket()
      Return the bit bucket for the OS. '/dev/null' for Unix and 'NUL' for Windows.
      Returns:
      a String containing the bit bucket
      Since:
      1.0
    • getCpuCores

      public static int getCpuCores()
      Returns the number of processor cores available to the JVM.
      Returns:
      an integer of the number of processor core
      Since:
      1.0.0
    • getMaxMemory

      public static long getMaxMemory()
      Returns the number of processor cores available to the JVM.
      Returns:
      an integer of the number of processor core
      Since:
      1.9.0