Class OsUtils

java.lang.Object
de.iip_ecosphere.platform.support.OsUtils

public class OsUtils extends Object
Access to static operating system level information.
Author:
Holger Eichelberger, SSE
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Preventing external creation.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    getBooleanPropertyOrEnv(String key, boolean dflt)
    Returns a boolean value from the system properties or system environment, either as given or all in capital characters with dots replaced by underscores.
    static String
    Returns a value from the system environment, either as given or all in capital characters with dots replaced by underscores.
    static final int
    Returns the number of CPU cores.
    static final String
    Returns the operating system architecture.
    static final String
    Returns the operating system name.
    static String
    Returns a value from the system properties or system environment, either as given or all in capital characters with dots replaced by underscores.
    static String
    Returns a value from the system properties or system environment, either as given or all in capital characters with dots replaced by underscores.
    static final String
    Returns the user.home System Property.
    static boolean
    Returns whether we are running on Java 1.8.
    static boolean
    Returns whether we are running on Linux.
    static boolean
    Returns whether we are running on Mac.
    static boolean
    Returns whether we are running on Unix.
    static boolean
    Returns whether we are running on windows.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OsUtils

      private OsUtils()
      Preventing external creation.
  • Method Details

    • getUserHome

      public static final String getUserHome()
      Returns the user.home System Property. User's home directory.
    • getOsName

      public static final String getOsName()
      Returns the operating system name.
      Returns:
      the operating system name
    • getOsArch

      public static final String getOsArch()
      Returns the operating system architecture.
      Returns:
      the operating system architecture.
    • getNumCpuCores

      public static final int getNumCpuCores()
      Returns the number of CPU cores.
      Returns:
      the number of CPU cores
    • getEnv

      public static String getEnv(String key)
      Returns a value from the system environment, either as given or all in capital characters with dots replaced by underscores.
      Parameters:
      key - the key to look for
      Returns:
      the value, may by null for none
    • getPropertyOrEnv

      public static String getPropertyOrEnv(String key, String dflt)
      Returns a value from the system properties or system environment, either as given or all in capital characters with dots replaced by underscores.
      Parameters:
      key - the key to look for
      dflt - the default value for none
      Returns:
      the value, may by dflt for none
      See Also:
    • getBooleanPropertyOrEnv

      public static boolean getBooleanPropertyOrEnv(String key, boolean dflt)
      Returns a boolean value from the system properties or system environment, either as given or all in capital characters with dots replaced by underscores.
      Parameters:
      key - the key to look for
      dflt - the default value for none
      Returns:
      the value, may by dflt for none
      See Also:
    • getPropertyOrEnv

      public static String getPropertyOrEnv(String key)
      Returns a value from the system properties or system environment, either as given or all in capital characters with dots replaced by underscores.
      Parameters:
      key - the key to look for
      Returns:
      the value, may by null for none
      See Also:
    • isWindows

      public static boolean isWindows()
      Returns whether we are running on windows.
      Returns:
      true for windows, false else
    • isLinux

      public static boolean isLinux()
      Returns whether we are running on Linux.
      Returns:
      true for Linux, false else
    • isUnix

      public static boolean isUnix()
      Returns whether we are running on Unix.
      Returns:
      true for Unix, false else
    • isMac

      public static boolean isMac()
      Returns whether we are running on Mac.
      Returns:
      true for Mac, false else
    • isJava1_8

      public static boolean isJava1_8()
      Returns whether we are running on Java 1.8.
      Returns:
      true for Java 1.8, false else