Class SystemUtils
- Since:
- 3.0.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanIstrueif this is AIX.static final booleanIstrueif this is Mac.static final booleanIstrueif this is Windows.private static final StringThe System property key for the Java home directory.static final StringTheline.separatorSystem Property.static final StringTheos.nameSystem Property.private static final StringThe prefix String for all Windows OS. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FileGets the Java home directory as aFile.private static booleangetOSMatchesName(String osNamePrefix) Decides if the operating system matches.private static StringgetSystemProperty(String property) Gets a System property, defaulting tonullif the property cannot be read.(package private) static booleanisOSNameMatch(String osName, String osNamePrefix) Decides if the operating system matches.
-
Field Details
-
OS_NAME
The
os.nameSystem Property. Operating system name.Defaults to
nullif 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)orSystem.setProperties(java.util.Properties)is called after this class is loaded, the value will be out of sync with that System property.- Since:
- Java 1.1
-
OS_NAME_WINDOWS_PREFIX
-
IS_OS_AIX
public static final boolean IS_OS_AIXIs
trueif this is AIX.The field will return
falseifOS_NAMEisnull. -
IS_OS_MAC_OSX
public static final boolean IS_OS_MAC_OSXIs
trueif this is Mac.The field will return
falseifOS_NAMEisnull. -
IS_OS_WINDOWS
public static final boolean IS_OS_WINDOWSIs
trueif this is Windows.The field will return
falseifOS_NAMEisnull. -
JAVA_HOME_KEY
The System property key for the Java home directory.- See Also:
-
LINE_SEPARATOR
The
line.separatorSystem Property. Line separator ("\n"on UNIX).Defaults to
nullif 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)orSystem.setProperties(java.util.Properties)is called after this class is loaded, the value will be out of sync with that System property.- Since:
- Java 1.1
-
-
Constructor Details
-
SystemUtils
SystemUtils()
-
-
Method Details
-
getOSMatchesName
Decides if the operating system matches.- Parameters:
osNamePrefix- the prefix for the os name- Returns:
- true if matches, or false if not or can't determine
-
isOSNameMatch
Decides if the operating system matches.This method is package private instead of private to support unit test invocation.
- Parameters:
osName- the actual OS nameosNamePrefix- the prefix for the expected OS name- Returns:
- true if matches, or false if not or can't determine
-
getJavaHome
Gets the Java home directory as a
File.- Returns:
- a directory
- Throws:
SecurityException- if a security manager exists and itscheckPropertyAccessmethod doesn't allow access to the specified system property.- Since:
- 2.1
- See Also:
-
getSystemProperty
Gets a System property, defaulting to
nullif the property cannot be read.If a
SecurityExceptionis caught, the return value isnulland a message is written toSystem.err.- Parameters:
property- the system property name- Returns:
- the system property value or
nullif a security problem occurs
-