class SystemUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static boolean |
IS_OS_AIX
Is
true if this is AIX. |
static boolean |
IS_OS_MAC_OSX
Is
true if this is Mac. |
static boolean |
IS_OS_WINDOWS
Is
true if this is Windows. |
private static java.lang.String |
JAVA_HOME_KEY
The System property key for the Java home directory.
|
static java.lang.String |
LINE_SEPARATOR
The
line.separator System Property. |
static java.lang.String |
OS_NAME
The
os.name System Property. |
private static java.lang.String |
OS_NAME_WINDOWS_PREFIX
The prefix String for all Windows OS.
|
| Constructor and Description |
|---|
SystemUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.io.File |
getJavaHome()
Gets the Java home directory as a
File. |
private static boolean |
getOSMatchesName(java.lang.String osNamePrefix)
Decides if the operating system matches.
|
private static java.lang.String |
getSystemProperty(java.lang.String property)
Gets a System property, defaulting to
null if the property cannot be read. |
(package private) static boolean |
isOSNameMatch(java.lang.String osName,
java.lang.String osNamePrefix)
Decides if the operating system matches.
|
public static final java.lang.String OS_NAME
The os.name System Property. Operating system name.
Defaults to null if the runtime does not have security access to read this property or the property does
not exist.
This value is initialized when the class is loaded. If System.setProperty(String,String) or
System.setProperties(java.util.Properties) is called after this class is loaded, the value will be out of
sync with that System property.
private static final java.lang.String OS_NAME_WINDOWS_PREFIX
public static final boolean IS_OS_AIX
Is true if this is AIX.
The field will return false if OS_NAME is null.
public static final boolean IS_OS_MAC_OSX
Is true if this is Mac.
The field will return false if OS_NAME is null.
public static final boolean IS_OS_WINDOWS
Is true if this is Windows.
The field will return false if OS_NAME is null.
private static final java.lang.String JAVA_HOME_KEY
public static final java.lang.String LINE_SEPARATOR
The line.separator System Property. Line separator ("\n" on UNIX).
Defaults to null if the runtime does not have security access to read this property or the property does
not exist.
This value is initialized when the class is loaded. If System.setProperty(String,String) or
System.setProperties(java.util.Properties) is called after this class is loaded, the value will be out of
sync with that System property.
private static boolean getOSMatchesName(java.lang.String osNamePrefix)
osNamePrefix - the prefix for the os namestatic boolean isOSNameMatch(java.lang.String osName,
java.lang.String osNamePrefix)
This method is package private instead of private to support unit test invocation.
osName - the actual OS nameosNamePrefix - the prefix for the expected OS namepublic static java.io.File getJavaHome()
Gets the Java home directory as a File.
java.lang.SecurityException - if a security manager exists and its checkPropertyAccess method doesn't allow
access to the specified system property.System.getProperty(String)private static java.lang.String getSystemProperty(java.lang.String property)
Gets a System property, defaulting to null if the property cannot be read.
If a SecurityException is caught, the return value is null and a message is written to
System.err.
property - the system property namenull if a security problem occurs