Class OsUtils
java.lang.Object
de.iip_ecosphere.platform.support.OsUtils
Access to static operating system level information.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleangetBooleanPropertyOrEnv(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 StringReturns a value from the system environment, either as given or all in capital characters with dots replaced by underscores.static FileGets the Java home directory as aFile.static StringThe Java Runtime Environment specification version.static final intReturns the number of CPU cores.static final StringReturns the operating system architecture.static final StringReturns the operating system name.static StringgetPropertyOrEnv(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.static StringgetPropertyOrEnv(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.static final StringReturns theuser.homeSystem Property.static booleanReturns whether we are running on Java 9 or newer.static booleanReturns whether we are running on Java 1.8.static booleanisLinux()Returns whether we are running on Linux.static booleanisMac()Returns whether we are running on Mac.static booleanisUnix()Returns whether we are running on Unix.static booleanReturns whether we are running on windows.
-
Field Details
-
PROP_JAVA_HOME
The System property key for the Java home directory.- See Also:
-
PROP_USER_HOME
The System property key for the user home directory.- See Also:
-
-
Constructor Details
-
OsUtils
private OsUtils()Preventing external creation.
-
-
Method Details
-
getUserHome
Returns theuser.homeSystem Property. User's home directory. -
getOsName
Returns the operating system name.- Returns:
- the operating system name
-
getJavaHome
Gets the Java home directory as aFile.- Returns:
- a directory
- Throws:
SecurityException- if a security manager exists and itscheckPropertyAccessmethod doesn't allow access to the specified system property.
-
getJavaSpecificationVersion
The Java Runtime Environment specification version. -
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
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
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 fordflt- the default value for none- Returns:
- the value, may by
dfltfor none - See Also:
-
getBooleanPropertyOrEnv
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 fordflt- the default value for none- Returns:
- the value, may by
dfltfor none - See Also:
-
getPropertyOrEnv
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:
truefor windows,falseelse
-
isLinux
public static boolean isLinux()Returns whether we are running on Linux.- Returns:
truefor Linux,falseelse
-
isUnix
public static boolean isUnix()Returns whether we are running on Unix.- Returns:
truefor Unix,falseelse
-
isMac
public static boolean isMac()Returns whether we are running on Mac.- Returns:
truefor Mac,falseelse
-
isJava1_8
public static boolean isJava1_8()Returns whether we are running on Java 1.8.- Returns:
truefor Java 1.8,falseelse
-
isAtLeastJava9
public static boolean isAtLeastJava9()Returns whether we are running on Java 9 or newer.- Returns:
truefor Java 9 nor newer,falseelse
-