Class SystemUtils
- java.lang.Object
-
- io.microsphere.util.SystemUtils
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFILE_ENCODINGThe System property for the file encoding, the default is "UTF-8"static java.lang.StringFILE_ENCODING_PROPERTY_KEYThe System property key for the file encoding : "file.encoding"static java.lang.StringFILE_SEPARATOR_PROPERTY_KEYThe System property key for the File separator ("/" on UNIX) : "file.separator"static booleanIS_JAVA_10Istrueif this is Java version 10.xstatic booleanIS_JAVA_11Istrueif this is Java version 11.xstatic booleanIS_JAVA_12Istrueif this is Java version 12.xstatic booleanIS_JAVA_13Istrueif this is Java version 13.xstatic booleanIS_JAVA_14Istrueif this is Java version 14.xstatic booleanIS_JAVA_15Istrueif this is Java version 15.xstatic booleanIS_JAVA_16Istrueif this is Java version 16.xstatic booleanIS_JAVA_17Istrueif this is Java version 17.xstatic booleanIS_JAVA_18Istrueif this is Java version 18.xstatic booleanIS_JAVA_19Istrueif this is Java version 19.xstatic booleanIS_JAVA_20Istrueif this is Java version 20.xstatic booleanIS_JAVA_21Istrueif this is Java version 21.xstatic booleanIS_JAVA_22Istrueif this is Java version 22.xstatic booleanIS_JAVA_23Istrueif this is Java version 23.xstatic booleanIS_JAVA_24Istrueif this is Java version 24.xstatic booleanIS_JAVA_8Istrueif this is Java 8static booleanIS_JAVA_9Istrueif this is Java version 9.xstatic booleanIS_LTS_JAVA_VERSIONIstrueif current Java version is Long Term Supported(LTS)static booleanIS_OS_WINDOWSIstrueif this is Windows.static java.lang.StringJAVA_CLASS_PATHThe System property for the Java class path.static java.lang.StringJAVA_CLASS_PATH_PROPERTY_KEYThe System property key for the Java class path : "java.class.path"static java.lang.StringJAVA_CLASS_VERSIONThe System property for the Java class format version number.static java.lang.StringJAVA_CLASS_VERSION_PROPERTY_KEYThe System property key for the Java class format version number : "java.class.version"static java.lang.StringJAVA_COMPILERThe System property for the Name of JIT compiler to use.static java.lang.StringJAVA_COMPILER_PROPERTY_KEYThe System property key for the Name of JIT compiler to use : "java.compiler"static java.lang.StringJAVA_EXT_DIRSThe System property for the Path of extension directory or directories Deprecated.static java.lang.StringJAVA_EXT_DIRS_PROPERTY_KEYDeprecated.static java.lang.StringJAVA_HOMEThe System property for the Java installation directory.static java.lang.StringJAVA_HOME_PROPERTY_KEYThe System property key for the Java installation directory : "java.home"static java.lang.StringJAVA_IO_TMPDIRThe System property for the Default temp file path.static java.lang.StringJAVA_IO_TMPDIR_PROPERTY_KEYThe System property key for the Default temp file path : "java.io.tmpdir"static java.lang.StringJAVA_LIBRARY_PATHThe System property for the List of paths to search when loading libraries.static java.lang.StringJAVA_LIBRARY_PATH_PROPERTY_KEYThe System property key for the List of paths to search when loading libraries : "java.library.path"static java.lang.StringJAVA_SPECIFICATION_NAMEThe System property for the Java Runtime Environment specification name.static java.lang.StringJAVA_SPECIFICATION_NAME_PROPERTY_KEYThe System property key for the Java Runtime Environment specification name : "java.specification.name"static java.lang.StringJAVA_SPECIFICATION_VENDORThe System property for the Java Runtime Environment specification vendor.static java.lang.StringJAVA_SPECIFICATION_VENDOR_PROPERTY_KEYThe System property key for the Java Runtime Environment specification vendor : "java.specification.vendor"static java.lang.StringJAVA_SPECIFICATION_VERSIONThe System property for the Java Runtime Environment specification version.static java.lang.StringJAVA_SPECIFICATION_VERSION_PROPERTY_KEYThe System property key for the Java Runtime Environment specification version : "java.specification.version"static java.lang.StringJAVA_VENDORThe System property for the Java Runtime Environment vendor.static java.lang.StringJAVA_VENDOR_PROPERTY_KEYThe System property key for the Java Runtime Environment vendor : "java.vendor"static java.lang.StringJAVA_VENDOR_URLThe System property for the Java vendor URL.static java.lang.StringJAVA_VENDOR_URL_PROPERTY_KEYThe System property key for the Java vendor URL : "java.vendor.url"static java.lang.StringJAVA_VERSIONThe System property for the Java Runtime Environment version.static java.lang.StringJAVA_VERSION_PROPERTY_KEYThe System property key for the Java Runtime Environment version : "java.version"static java.lang.StringJAVA_VM_NAMEThe System property for the Java Virtual Machine implementation name.static java.lang.StringJAVA_VM_NAME_PROPERTY_KEYThe System property key for the Java Virtual Machine implementation name : "java.vm.name"static java.lang.StringJAVA_VM_SPECIFICATION_NAMEThe System property for the Java Virtual Machine specification name.static java.lang.StringJAVA_VM_SPECIFICATION_NAME_PROPERTY_KEYThe System property key for the Java Virtual Machine specification name : "java.vm.specification.name"static java.lang.StringJAVA_VM_SPECIFICATION_VENDORThe System property for the Java Virtual Machine specification vendor.static java.lang.StringJAVA_VM_SPECIFICATION_VENDOR_PROPERTY_KEYThe System property key for the Java Virtual Machine specification vendor : "java.vm.specification.vendor"static java.lang.StringJAVA_VM_SPECIFICATION_VERSIONThe System property for the Java Virtual Machine specification version.static java.lang.StringJAVA_VM_SPECIFICATION_VERSION_PROPERTY_KEYThe System property key for the Java Virtual Machine specification version : "java.vm.specification.version"static java.lang.StringJAVA_VM_VENDORThe System property for the Java Virtual Machine implementation vendor.static java.lang.StringJAVA_VM_VENDOR_PROPERTY_KEYThe System property key for the Java Virtual Machine implementation vendor : "java.vm.vendor"static java.lang.StringJAVA_VM_VERSIONThe System property for the Java Virtual Machine implementation version.static java.lang.StringJAVA_VM_VERSION_PROPERTY_KEYThe System property key for the Java Virtual Machine implementation version : "java.vm.version"static java.lang.StringLINE_SEPARATOR_PROPERTY_KEYThe System property key for the Line separator ("\n" on UNIX) : "line.separator"static java.lang.StringNATIVE_ENCODINGThe System property for the native encodingstatic java.lang.StringNATIVE_ENCODING_PROPERTY_KEYThe System property key for the native encoding : "native.encoding"static java.lang.StringOS_ARCHThe System property for the Operating system architecture.static java.lang.StringOS_ARCH_PROPERTY_KEYThe System property key for the Operating system architecture : "os.arch"static java.lang.StringOS_NAMEThe System property for the Operating system name.static java.lang.StringOS_NAME_PROPERTY_KEYThe System property key for the Operating system name : "os.name"static java.lang.StringOS_NAME_WINDOWS_PREFIXstatic java.lang.StringOS_VERSIONThe System property for the Operating system version.static java.lang.StringOS_VERSION_PROPERTY_KEYThe System property key for the Operating system version : "os.version"static java.lang.StringPATH_SEPARATOR_PROPERTY_KEYThe System property key for the Path separator (":" on UNIX) : "path.separator"static java.lang.StringUSER_DIRThe System property for the User's current working directory.static java.lang.StringUSER_DIR_PROPERTY_KEYThe System property key for the User's current working directory : "user.dir"static java.lang.StringUSER_HOMEThe System property for the User's home directory.static java.lang.StringUSER_HOME_PROPERTY_KEYThe System property key for the User's home directory : "user.home"static java.lang.StringUSER_NAMEThe System property for the User's account name.static java.lang.StringUSER_NAME_PROPERTY_KEYThe System property key for the User's account name : "user.name"
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcopySystemProperties()Copies the current system properties into an internal map for later access.static java.lang.StringgetSystemProperty(java.lang.String key)Gets a system property with the given key, defaulting tonullif the property cannot be read.static java.lang.StringgetSystemProperty(java.lang.String key, java.lang.String defaultValue)Gets a system property with the given key, defaulting to the provideddefaultValueif the property cannot be read.protected static java.lang.StringgetSystemPropertyFromCopy(java.lang.String key)protected static voidresetSystemPropertiesCopy()Reset thesystemPropertiesCopyto benull, mainly used for testing
-
-
-
Field Detail
-
OS_NAME_WINDOWS_PREFIX
public static final java.lang.String OS_NAME_WINDOWS_PREFIX
- See Also:
- Constant Field Values
-
JAVA_CLASS_PATH_PROPERTY_KEY
public static final java.lang.String JAVA_CLASS_PATH_PROPERTY_KEY
The System property key for the Java class path : "java.class.path"- See Also:
- Constant Field Values
-
USER_NAME_PROPERTY_KEY
public static final java.lang.String USER_NAME_PROPERTY_KEY
The System property key for the User's account name : "user.name"- See Also:
- Constant Field Values
-
JAVA_EXT_DIRS_PROPERTY_KEY
@Deprecated public static final java.lang.String JAVA_EXT_DIRS_PROPERTY_KEY
Deprecated.The System property key for the Path of extension directory or directories Deprecated. This property, and the mechanism which implements it, may be removed in a future release : "java.ext.dirs"- See Also:
- Constant Field Values
-
JAVA_VENDOR_PROPERTY_KEY
public static final java.lang.String JAVA_VENDOR_PROPERTY_KEY
The System property key for the Java Runtime Environment vendor : "java.vendor"- See Also:
- Constant Field Values
-
JAVA_SPECIFICATION_VERSION_PROPERTY_KEY
public static final java.lang.String JAVA_SPECIFICATION_VERSION_PROPERTY_KEY
The System property key for the Java Runtime Environment specification version : "java.specification.version"- See Also:
- Constant Field Values
-
LINE_SEPARATOR_PROPERTY_KEY
public static final java.lang.String LINE_SEPARATOR_PROPERTY_KEY
The System property key for the Line separator ("\n" on UNIX) : "line.separator"- See Also:
- Constant Field Values
-
JAVA_CLASS_VERSION_PROPERTY_KEY
public static final java.lang.String JAVA_CLASS_VERSION_PROPERTY_KEY
The System property key for the Java class format version number : "java.class.version"- See Also:
- Constant Field Values
-
JAVA_SPECIFICATION_NAME_PROPERTY_KEY
public static final java.lang.String JAVA_SPECIFICATION_NAME_PROPERTY_KEY
The System property key for the Java Runtime Environment specification name : "java.specification.name"- See Also:
- Constant Field Values
-
JAVA_VENDOR_URL_PROPERTY_KEY
public static final java.lang.String JAVA_VENDOR_URL_PROPERTY_KEY
The System property key for the Java vendor URL : "java.vendor.url"- See Also:
- Constant Field Values
-
JAVA_VM_VERSION_PROPERTY_KEY
public static final java.lang.String JAVA_VM_VERSION_PROPERTY_KEY
The System property key for the Java Virtual Machine implementation version : "java.vm.version"- See Also:
- Constant Field Values
-
OS_NAME_PROPERTY_KEY
public static final java.lang.String OS_NAME_PROPERTY_KEY
The System property key for the Operating system name : "os.name"- See Also:
- Constant Field Values
-
OS_ARCH_PROPERTY_KEY
public static final java.lang.String OS_ARCH_PROPERTY_KEY
The System property key for the Operating system architecture : "os.arch"- See Also:
- Constant Field Values
-
JAVA_HOME_PROPERTY_KEY
public static final java.lang.String JAVA_HOME_PROPERTY_KEY
The System property key for the Java installation directory : "java.home"- See Also:
- Constant Field Values
-
OS_VERSION_PROPERTY_KEY
public static final java.lang.String OS_VERSION_PROPERTY_KEY
The System property key for the Operating system version : "os.version"- See Also:
- Constant Field Values
-
JAVA_COMPILER_PROPERTY_KEY
public static final java.lang.String JAVA_COMPILER_PROPERTY_KEY
The System property key for the Name of JIT compiler to use : "java.compiler"- See Also:
- Constant Field Values
-
JAVA_VERSION_PROPERTY_KEY
public static final java.lang.String JAVA_VERSION_PROPERTY_KEY
The System property key for the Java Runtime Environment version : "java.version"- See Also:
- Constant Field Values
-
JAVA_VM_SPECIFICATION_VERSION_PROPERTY_KEY
public static final java.lang.String JAVA_VM_SPECIFICATION_VERSION_PROPERTY_KEY
The System property key for the Java Virtual Machine specification version : "java.vm.specification.version"- See Also:
- Constant Field Values
-
USER_DIR_PROPERTY_KEY
public static final java.lang.String USER_DIR_PROPERTY_KEY
The System property key for the User's current working directory : "user.dir"- See Also:
- Constant Field Values
-
JAVA_SPECIFICATION_VENDOR_PROPERTY_KEY
public static final java.lang.String JAVA_SPECIFICATION_VENDOR_PROPERTY_KEY
The System property key for the Java Runtime Environment specification vendor : "java.specification.vendor"- See Also:
- Constant Field Values
-
JAVA_VM_SPECIFICATION_NAME_PROPERTY_KEY
public static final java.lang.String JAVA_VM_SPECIFICATION_NAME_PROPERTY_KEY
The System property key for the Java Virtual Machine specification name : "java.vm.specification.name"- See Also:
- Constant Field Values
-
JAVA_VM_VENDOR_PROPERTY_KEY
public static final java.lang.String JAVA_VM_VENDOR_PROPERTY_KEY
The System property key for the Java Virtual Machine implementation vendor : "java.vm.vendor"- See Also:
- Constant Field Values
-
FILE_SEPARATOR_PROPERTY_KEY
public static final java.lang.String FILE_SEPARATOR_PROPERTY_KEY
The System property key for the File separator ("/" on UNIX) : "file.separator"- See Also:
- Constant Field Values
-
PATH_SEPARATOR_PROPERTY_KEY
public static final java.lang.String PATH_SEPARATOR_PROPERTY_KEY
The System property key for the Path separator (":" on UNIX) : "path.separator"- See Also:
- Constant Field Values
-
JAVA_LIBRARY_PATH_PROPERTY_KEY
public static final java.lang.String JAVA_LIBRARY_PATH_PROPERTY_KEY
The System property key for the List of paths to search when loading libraries : "java.library.path"- See Also:
- Constant Field Values
-
USER_HOME_PROPERTY_KEY
public static final java.lang.String USER_HOME_PROPERTY_KEY
The System property key for the User's home directory : "user.home"- See Also:
- Constant Field Values
-
JAVA_VM_NAME_PROPERTY_KEY
public static final java.lang.String JAVA_VM_NAME_PROPERTY_KEY
The System property key for the Java Virtual Machine implementation name : "java.vm.name"- See Also:
- Constant Field Values
-
JAVA_VM_SPECIFICATION_VENDOR_PROPERTY_KEY
public static final java.lang.String JAVA_VM_SPECIFICATION_VENDOR_PROPERTY_KEY
The System property key for the Java Virtual Machine specification vendor : "java.vm.specification.vendor"- See Also:
- Constant Field Values
-
JAVA_IO_TMPDIR_PROPERTY_KEY
public static final java.lang.String JAVA_IO_TMPDIR_PROPERTY_KEY
The System property key for the Default temp file path : "java.io.tmpdir"- See Also:
- Constant Field Values
-
FILE_ENCODING_PROPERTY_KEY
public static final java.lang.String FILE_ENCODING_PROPERTY_KEY
The System property key for the file encoding : "file.encoding"- See Also:
- Constant Field Values
-
NATIVE_ENCODING_PROPERTY_KEY
public static final java.lang.String NATIVE_ENCODING_PROPERTY_KEY
The System property key for the native encoding : "native.encoding"- See Also:
- Constant Field Values
-
JAVA_CLASS_PATH
public static final java.lang.String JAVA_CLASS_PATH
The System property for the Java class path.
-
USER_NAME
public static final java.lang.String USER_NAME
The System property for the User's account name.
-
JAVA_EXT_DIRS
public static final java.lang.String JAVA_EXT_DIRS
The System property for the Path of extension directory or directories Deprecated. This property, and the mechanism which implements it, may be removed in a future release..
-
JAVA_VENDOR
public static final java.lang.String JAVA_VENDOR
The System property for the Java Runtime Environment vendor.
-
JAVA_SPECIFICATION_VERSION
public static final java.lang.String JAVA_SPECIFICATION_VERSION
The System property for the Java Runtime Environment specification version.
-
JAVA_CLASS_VERSION
public static final java.lang.String JAVA_CLASS_VERSION
The System property for the Java class format version number.
-
JAVA_SPECIFICATION_NAME
public static final java.lang.String JAVA_SPECIFICATION_NAME
The System property for the Java Runtime Environment specification name.
-
JAVA_VENDOR_URL
public static final java.lang.String JAVA_VENDOR_URL
The System property for the Java vendor URL.
-
JAVA_VM_VERSION
public static final java.lang.String JAVA_VM_VERSION
The System property for the Java Virtual Machine implementation version.
-
OS_NAME
public static final java.lang.String OS_NAME
The System property for the Operating system name.
-
OS_ARCH
public static final java.lang.String OS_ARCH
The System property for the Operating system architecture.
-
JAVA_HOME
public static final java.lang.String JAVA_HOME
The System property for the Java installation directory.
-
OS_VERSION
public static final java.lang.String OS_VERSION
The System property for the Operating system version.
-
JAVA_COMPILER
public static final java.lang.String JAVA_COMPILER
The System property for the Name of JIT compiler to use.
-
JAVA_VERSION
public static final java.lang.String JAVA_VERSION
The System property for the Java Runtime Environment version.
-
JAVA_VM_SPECIFICATION_VERSION
public static final java.lang.String JAVA_VM_SPECIFICATION_VERSION
The System property for the Java Virtual Machine specification version.
-
USER_DIR
public static final java.lang.String USER_DIR
The System property for the User's current working directory.
-
JAVA_SPECIFICATION_VENDOR
public static final java.lang.String JAVA_SPECIFICATION_VENDOR
The System property for the Java Runtime Environment specification vendor.
-
JAVA_VM_SPECIFICATION_NAME
public static final java.lang.String JAVA_VM_SPECIFICATION_NAME
The System property for the Java Virtual Machine specification name.
-
JAVA_VM_VENDOR
public static final java.lang.String JAVA_VM_VENDOR
The System property for the Java Virtual Machine implementation vendor.
-
JAVA_LIBRARY_PATH
public static final java.lang.String JAVA_LIBRARY_PATH
The System property for the List of paths to search when loading libraries.
-
USER_HOME
public static final java.lang.String USER_HOME
The System property for the User's home directory.
-
JAVA_VM_NAME
public static final java.lang.String JAVA_VM_NAME
The System property for the Java Virtual Machine implementation name.
-
JAVA_VM_SPECIFICATION_VENDOR
public static final java.lang.String JAVA_VM_SPECIFICATION_VENDOR
The System property for the Java Virtual Machine specification vendor.
-
JAVA_IO_TMPDIR
public static final java.lang.String JAVA_IO_TMPDIR
The System property for the Default temp file path.
-
FILE_ENCODING
public static final java.lang.String FILE_ENCODING
The System property for the file encoding, the default is "UTF-8"
-
NATIVE_ENCODING
public static final java.lang.String NATIVE_ENCODING
The System property for the native encoding
-
IS_OS_WINDOWS
public static final boolean IS_OS_WINDOWS
Is
trueif this is Windows.The field will return
falseifOS_NAMEisnull.
-
IS_JAVA_8
public static final boolean IS_JAVA_8
Is
trueif this is Java 8The field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_9
public static final boolean IS_JAVA_9
Is
trueif this is Java version 9.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_10
public static final boolean IS_JAVA_10
Is
trueif this is Java version 10.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_11
public static final boolean IS_JAVA_11
Is
trueif this is Java version 11.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_12
public static final boolean IS_JAVA_12
Is
trueif this is Java version 12.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_13
public static final boolean IS_JAVA_13
Is
trueif this is Java version 13.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_14
public static final boolean IS_JAVA_14
Is
trueif this is Java version 14.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_15
public static final boolean IS_JAVA_15
Is
trueif this is Java version 15.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_16
public static final boolean IS_JAVA_16
Is
trueif this is Java version 16.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_17
public static final boolean IS_JAVA_17
Is
trueif this is Java version 17.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_18
public static final boolean IS_JAVA_18
Is
trueif this is Java version 18.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_19
public static final boolean IS_JAVA_19
Is
trueif this is Java version 19.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_20
public static final boolean IS_JAVA_20
Is
trueif this is Java version 20.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_21
public static final boolean IS_JAVA_21
Is
trueif this is Java version 21.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_22
public static final boolean IS_JAVA_22
Is
trueif this is Java version 22.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_23
public static final boolean IS_JAVA_23
Is
trueif this is Java version 23.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_JAVA_24
public static final boolean IS_JAVA_24
Is
trueif this is Java version 24.xThe field will return
falseifJAVA_VERSIONisnull.
-
IS_LTS_JAVA_VERSION
public static final boolean IS_LTS_JAVA_VERSION
Istrueif current Java version is Long Term Supported(LTS)
-
-
Method Detail
-
copySystemProperties
public static void copySystemProperties()
Copies the current system properties into an internal map for later access.
This method is useful when you want to capture the system properties at a certain point in time and access them later without querying the system again. It ensures that the properties are copied in a thread-safe manner.
Example Usage
SystemUtils.copySystemProperties();
-
getSystemProperty
@Nullable public static java.lang.String getSystemProperty(java.lang.String key)
Gets a system property with the given key, defaulting to
If anullif the property cannot be read.SecurityExceptionis caught, the return value isnulland a message is written toSystem.err.Example Usage
String javaVersion = SystemUtils.getSystemProperty("java.version");- Parameters:
key- the name of the system property- Returns:
- the string value of the system property, or
nullif the property is not found or access is denied
-
getSystemProperty
@Nullable public static java.lang.String getSystemProperty(java.lang.String key, java.lang.String defaultValue)
Gets a system property with the given key, defaulting to the provided
defaultValueif the property cannot be read.If a
SecurityExceptionis caught while trying to access the system property, the method returns the specified default value and logs a warning message using the logger associated with this class.Example Usage
String customProperty = SystemUtils.getSystemProperty("my.custom.property", "default-value");- Parameters:
key- the name of the system propertydefaultValue- the default value to return if the property is not found or access is denied- Returns:
- the string value of the system property, or the provided default value if the property is inaccessible or not found
-
resetSystemPropertiesCopy
protected static void resetSystemPropertiesCopy()
Reset thesystemPropertiesCopyto benull, mainly used for testing
-
getSystemPropertyFromCopy
protected static java.lang.String getSystemPropertyFromCopy(java.lang.String key)
-
-