Package com.helger.commons.system
Class SystemProperties
- java.lang.Object
-
- com.helger.commons.system.SystemProperties
-
- All Implemented Interfaces:
IHasConditionalLogger
@ThreadSafe public final class SystemProperties extends Object implements IHasConditionalLogger
This class wraps all the Java system properties like version number etc.- Author:
- Philip Helger
-
-
Field Summary
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclearWarnedPropertyNames()Clear the cache with the property names, for which warnings were emitted that keys don't exist.static booleancontainsPropertyName(String sPropertyName)Check if a system property with the given name exists.static String[]getAllJavaNetSystemProperties()Get a set of system property names which are relevant for network debugging/proxy handling.static ICommonsMap<String,String>getAllProperties()static ICommonsSet<String>getAllPropertyNames()static ICommonsSet<String>getAllWarnedPropertyNames()static StringgetFileSeparator()static StringgetJavaClassPath()static StringgetJavaClassVersion()static StringgetJavaHome()static StringgetJavaLibraryPath()static StringgetJavaRuntimeName()static StringgetJavaRuntimeVersion()static StringgetJavaSpecificationUrl()static StringgetJavaSpecificationVendor()static StringgetJavaSpecificationVersion()static StringgetJavaVendor()static StringgetJavaVendorURL()static StringgetJavaVersion()static StringgetJavaVmName()static StringgetJavaVmSpecificationUrl()static StringgetJavaVmSpecificationVendor()static StringgetJavaVmSpecificationVersion()static StringgetJavaVmUrl()static StringgetJavaVmVendor()static StringgetJavaVmVersion()static StringgetLineSeparator()static StringgetOsArch()static StringgetOsName()static StringgetOsVersion()static StringgetPathSeparator()static StringgetPropertyValue(String sKey)static StringgetPropertyValueOrNull(String sKey)static StringgetTmpDir()static StringgetUserDir()static StringgetUserHome()static StringgetUserName()static booleanisSilentMode()static StringremovePropertyValue(String sKey)Remove a system property value under consideration of an eventually presentSecurityManager.static EChangesetPropertyValue(String sKey, boolean bValue)Set a system property value under consideration of an eventually presentSecurityManager.static EChangesetPropertyValue(String sKey, int nValue)Set a system property value under consideration of an eventually presentSecurityManager.static EChangesetPropertyValue(String sKey, long nValue)Set a system property value under consideration of an eventually presentSecurityManager.static EChangesetPropertyValue(String sKey, String sValue)Set a system property value under consideration of an eventually presentSecurityManager.static booleansetSilentMode(boolean bSilentMode)Enable or disable certain regular log messages.
-
-
-
Field Detail
-
SYSTEM_PROPERTY_FILE_SEPARATOR
public static final String SYSTEM_PROPERTY_FILE_SEPARATOR
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_CLASS_PATH
public static final String SYSTEM_PROPERTY_JAVA_CLASS_PATH
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_CLASS_VERSION
public static final String SYSTEM_PROPERTY_JAVA_CLASS_VERSION
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_LIBRARY_PATH
public static final String SYSTEM_PROPERTY_JAVA_LIBRARY_PATH
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_HOME
public static final String SYSTEM_PROPERTY_JAVA_HOME
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_IO_TMPDIR
public static final String SYSTEM_PROPERTY_JAVA_IO_TMPDIR
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_RUNTIME_NAME
public static final String SYSTEM_PROPERTY_JAVA_RUNTIME_NAME
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_RUNTIME_VERSION
public static final String SYSTEM_PROPERTY_JAVA_RUNTIME_VERSION
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_SPECIFICATION_URL
public static final String SYSTEM_PROPERTY_JAVA_SPECIFICATION_URL
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_SPECIFICATION_VENDOR
public static final String SYSTEM_PROPERTY_JAVA_SPECIFICATION_VENDOR
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_SPECIFICATION_VERSION
public static final String SYSTEM_PROPERTY_JAVA_SPECIFICATION_VERSION
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_VENDOR
public static final String SYSTEM_PROPERTY_JAVA_VENDOR
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_VENDOR_URL
public static final String SYSTEM_PROPERTY_JAVA_VENDOR_URL
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_VERSION
public static final String SYSTEM_PROPERTY_JAVA_VERSION
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_VM_NAME
public static final String SYSTEM_PROPERTY_JAVA_VM_NAME
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_VM_SPECIFICATION_URL
public static final String SYSTEM_PROPERTY_JAVA_VM_SPECIFICATION_URL
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_VM_SPECIFICATION_VENDOR
public static final String SYSTEM_PROPERTY_JAVA_VM_SPECIFICATION_VENDOR
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_VM_SPECIFICATION_VERSION
public static final String SYSTEM_PROPERTY_JAVA_VM_SPECIFICATION_VERSION
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_VM_URL
public static final String SYSTEM_PROPERTY_JAVA_VM_URL
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_VM_VENDOR
public static final String SYSTEM_PROPERTY_JAVA_VM_VENDOR
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_JAVA_VM_VERSION
public static final String SYSTEM_PROPERTY_JAVA_VM_VERSION
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_LINE_SEPARATOR
public static final String SYSTEM_PROPERTY_LINE_SEPARATOR
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_OS_ARCH
public static final String SYSTEM_PROPERTY_OS_ARCH
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_OS_NAME
public static final String SYSTEM_PROPERTY_OS_NAME
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_OS_VERSION
public static final String SYSTEM_PROPERTY_OS_VERSION
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_PATH_SEPARATOR
public static final String SYSTEM_PROPERTY_PATH_SEPARATOR
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_USER_DIR
public static final String SYSTEM_PROPERTY_USER_DIR
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_USER_HOME
public static final String SYSTEM_PROPERTY_USER_HOME
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_USER_NAME
public static final String SYSTEM_PROPERTY_USER_NAME
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_SUN_IO_SERIALIZATION_EXTENDEDDEBUGINFO
public static final String SYSTEM_PROPERTY_SUN_IO_SERIALIZATION_EXTENDEDDEBUGINFO
- See Also:
- Constant Field Values
-
-
Method Detail
-
isSilentMode
public static boolean isSilentMode()
- Returns:
trueif logging is disabled,falseif it is enabled.
-
setSilentMode
public static boolean setSilentMode(boolean bSilentMode)
Enable or disable certain regular log messages.- Parameters:
bSilentMode-trueto disable logging,falseto enable logging- Returns:
- The previous value of the silent mode.
-
getPropertyValueOrNull
@Nullable public static String getPropertyValueOrNull(@Nullable String sKey)
-
clearWarnedPropertyNames
public static void clearWarnedPropertyNames()
Clear the cache with the property names, for which warnings were emitted that keys don't exist.
-
getAllWarnedPropertyNames
@Nonnull @ReturnsMutableCopy public static ICommonsSet<String> getAllWarnedPropertyNames()
- Returns:
- A copy of the set with all property names for which warnings were emitted.
-
setPropertyValue
@Nonnull public static EChange setPropertyValue(@Nonnull String sKey, boolean bValue)
Set a system property value under consideration of an eventually presentSecurityManager.- Parameters:
sKey- The key of the system property. May not benull.bValue- The value of the system property.- Returns:
EChange
-
setPropertyValue
@Nonnull public static EChange setPropertyValue(@Nonnull String sKey, int nValue)
Set a system property value under consideration of an eventually presentSecurityManager.- Parameters:
sKey- The key of the system property. May not benull.nValue- The value of the system property.- Returns:
EChange- Since:
- 8.5.7
-
setPropertyValue
@Nonnull public static EChange setPropertyValue(@Nonnull String sKey, long nValue)
Set a system property value under consideration of an eventually presentSecurityManager.- Parameters:
sKey- The key of the system property. May not benull.nValue- The value of the system property.- Returns:
EChange- Since:
- 8.5.7
-
setPropertyValue
@Nonnull public static EChange setPropertyValue(@Nonnull String sKey, @Nullable String sValue)
Set a system property value under consideration of an eventually presentSecurityManager.- Parameters:
sKey- The key of the system property. May not benull.sValue- The value of the system property. If the value isnullthe property is removed.- Returns:
EChange
-
removePropertyValue
@Nullable public static String removePropertyValue(@Nonnull String sKey)
Remove a system property value under consideration of an eventually presentSecurityManager.- Parameters:
sKey- The key of the system property to be removed. May not benull.- Returns:
- the previous string value of the system property, or
nullif there was no property with that key.
-
getJavaVersion
@Nullable public static String getJavaVersion()
- Returns:
- System property value
java.version
-
getJavaVendor
@Nullable public static String getJavaVendor()
- Returns:
- System property value
java.vendor
-
getJavaVendorURL
@Nullable public static String getJavaVendorURL()
- Returns:
- System property value
java.vendor.url
-
getJavaClassVersion
@Nullable public static String getJavaClassVersion()
- Returns:
- System property value
java.class.version
-
getJavaClassPath
@Nullable public static String getJavaClassPath()
- Returns:
- System property value
java.class.path
-
getJavaLibraryPath
@Nullable public static String getJavaLibraryPath()
- Returns:
- System property value
java.library.path
-
getOsVersion
@Nullable public static String getOsVersion()
- Returns:
- System property value
os.version
-
getFileSeparator
@Nullable public static String getFileSeparator()
- Returns:
- System property value
file.separator
-
getPathSeparator
@Nullable public static String getPathSeparator()
- Returns:
- System property value
path.separator
-
getLineSeparator
@Nullable public static String getLineSeparator()
- Returns:
- System property value
line.separator
-
getJavaVmName
@Nullable public static String getJavaVmName()
- Returns:
- System property value
java.vm.name
-
getJavaVmSpecificationVersion
@Nullable public static String getJavaVmSpecificationVersion()
- Returns:
- System property value
java.vm.specification.version
-
getJavaVmSpecificationVendor
@Nullable public static String getJavaVmSpecificationVendor()
- Returns:
- System property value
java.vm.specification.vendor
-
getJavaVmSpecificationUrl
@Nullable public static String getJavaVmSpecificationUrl()
- Returns:
- System property value
java.vm.specification.url
-
getJavaVmVersion
@Nullable public static String getJavaVmVersion()
- Returns:
- System property value
java.vm.version
-
getJavaVmVendor
@Nullable public static String getJavaVmVendor()
- Returns:
- System property value
java.vm.vendor
-
getJavaVmUrl
@Nullable public static String getJavaVmUrl()
- Returns:
- System property value
java.vm.url
-
getJavaSpecificationVersion
@Nullable public static String getJavaSpecificationVersion()
- Returns:
- System property value
java.specification.version
-
getJavaSpecificationVendor
@Nullable public static String getJavaSpecificationVendor()
- Returns:
- System property value
java.specification.vendor
-
getJavaSpecificationUrl
@Nullable public static String getJavaSpecificationUrl()
- Returns:
- System property value
java.specification.url
-
getTmpDir
@DevelopersNote("This property is not part of the language but part of the Sun SDK") @Nullable public static String getTmpDir()
- Returns:
- System property value
java.io.tmpdir
-
getJavaRuntimeVersion
@Nullable public static String getJavaRuntimeVersion()
- Returns:
- System property value
java.runtime.version
-
getJavaRuntimeName
@Nullable public static String getJavaRuntimeName()
- Returns:
- System property value
java.runtime.version
-
getAllPropertyNames
@Nonnull @ReturnsMutableCopy public static ICommonsSet<String> getAllPropertyNames()
- Returns:
- A set with all defined property names. Never
null.
-
getAllProperties
@Nonnull @ReturnsMutableCopy public static ICommonsMap<String,String> getAllProperties()
- Returns:
- A map with all system properties where the key is the system property name and the value is the system property value.
-
containsPropertyName
public static boolean containsPropertyName(String sPropertyName)
Check if a system property with the given name exists.- Parameters:
sPropertyName- The name of the property.- Returns:
trueif such a system property is present,falseotherwise
-
getAllJavaNetSystemProperties
@Nonnull @ReturnsMutableCopy public static String[] getAllJavaNetSystemProperties()
Get a set of system property names which are relevant for network debugging/proxy handling. This method is meant to be used for reading the appropriate settings from a configuration file.- Returns:
- An array with all system property names which are relevant for
debugging/proxy handling. Never
nulland never empty. Each call returns a new array.
-
-