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 Details

  • Method Details

    • isSilentMode

      public static boolean isSilentMode()
      Returns:
      true if logging is disabled, false if it is enabled.
    • setSilentMode

      public static boolean setSilentMode(boolean bSilentMode)
      Enable or disable certain regular log messages.
      Parameters:
      bSilentMode - true to disable logging, false to enable logging
      Returns:
      The previous value of the silent mode.
    • getPropertyValueOrNull

      @Nullable public static String getPropertyValueOrNull(@Nullable String sKey)
    • getPropertyValue

      @Nullable public static String getPropertyValue(@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 present SecurityManager.
      Parameters:
      sKey - The key of the system property. May not be null.
      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 present SecurityManager.
      Parameters:
      sKey - The key of the system property. May not be null.
      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 present SecurityManager.
      Parameters:
      sKey - The key of the system property. May not be null.
      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 present SecurityManager.
      Parameters:
      sKey - The key of the system property. May not be null.
      sValue - The value of the system property. If the value is null the property is removed.
      Returns:
      EChange
    • removePropertyValue

      @Nullable public static String removePropertyValue(@Nonnull String sKey)
      Remove a system property value under consideration of an eventually present SecurityManager.
      Parameters:
      sKey - The key of the system property to be removed. May not be null.
      Returns:
      the previous string value of the system property, or null if 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
    • getJavaHome

      @Nullable public static String getJavaHome()
      Returns:
      System property value java.home
    • 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
    • getOsName

      @Nullable public static String getOsName()
      Returns:
      System property value os.name
    • getOsArch

      @Nullable public static String getOsArch()
      Returns:
      System property value os.arch
    • 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
    • getUserName

      @Nullable public static String getUserName()
      Returns:
      System property value user.name
    • getUserHome

      @Nullable public static String getUserHome()
      Returns:
      System property value user.home
    • getUserDir

      @Nullable public static String getUserDir()
      Returns:
      System property value user.dir
    • 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:
      true if such a system property is present, false otherwise
    • 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 null and never empty. Each call returns a new array.