Class SystemProperties

java.lang.Object
com.helger.base.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

    • JAVA_CLASS_VERSION

      public static final double JAVA_CLASS_VERSION
      The global Java class version as a double value.
  • 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

      public static @Nullable String getPropertyValueOrNull(@Nullable String sKey)
      Get the value of the system property with the given key without issuing a warning if the property is not set.
      Parameters:
      sKey - The key of the system property. May be null.
      Returns:
      null if the key is null or if the property is not set.
    • getPropertyValue

      public static @Nullable String getPropertyValue(@Nullable String sKey)
      Get the value of the system property with the given key. If the property is not set, a warning is logged once per property name.
      Parameters:
      sKey - The key of the system property. May be null.
      Returns:
      null if the key is null or if the property is not set.
    • clearWarnedPropertyNames

      public static void clearWarnedPropertyNames()
      Clear the cache with the property names, for which warnings were emitted that keys don't exist.
    • getAllWarnedPropertyNames

      @ReturnsMutableCopy public static @NonNull Set<String> getAllWarnedPropertyNames()
      Returns:
      A copy of the set with all property names for which warnings were emitted.
    • setPropertyValue

      public static @NonNull EChange setPropertyValue(@NonNull String sKey, boolean bValue)
      Set a system property value.
      Parameters:
      sKey - The key of the system property. May not be null.
      bValue - The value of the system property.
      Returns:
      EChange
    • setPropertyValue

      public static @NonNull EChange setPropertyValue(@NonNull String sKey, int nValue)
      Set a system property value .
      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

      public static @NonNull EChange setPropertyValue(@NonNull String sKey, long nValue)
      Set a system property value
      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

      public static @NonNull EChange setPropertyValue(@NonNull String sKey, @Nullable String sValue)
      Set a system property value
      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

      public static @Nullable String removePropertyValue(@NonNull String sKey)
      Remove a system property value
      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

      public static @Nullable String getJavaVersion()
      Returns:
      System property value java.version
    • getJavaVendor

      public static @Nullable String getJavaVendor()
      Returns:
      System property value java.vendor
    • getJavaVendorURL

      public static @Nullable String getJavaVendorURL()
      Returns:
      System property value java.vendor.url
    • getJavaHome

      public static @Nullable String getJavaHome()
      Returns:
      System property value java.home
    • getJavaClassVersion

      public static @Nullable String getJavaClassVersion()
      Returns:
      System property value java.class.version
    • getJavaClassPath

      public static @Nullable String getJavaClassPath()
      Returns:
      System property value java.class.path
    • getJavaLibraryPath

      public static @Nullable String getJavaLibraryPath()
      Returns:
      System property value java.library.path
    • getOsName

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

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

      public static @Nullable String getOsVersion()
      Returns:
      System property value os.version
    • getFileSeparator

      public static @Nullable String getFileSeparator()
      Returns:
      System property value file.separator
    • getPathSeparator

      public static @Nullable String getPathSeparator()
      Returns:
      System property value path.separator
    • getLineSeparator

      public static @Nullable String getLineSeparator()
      Returns:
      System property value line.separator
    • getUserName

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

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

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

      public static @Nullable String getJavaVmName()
      Returns:
      System property value java.vm.name
    • getJavaVmSpecificationVersion

      public static @Nullable String getJavaVmSpecificationVersion()
      Returns:
      System property value java.vm.specification.version
    • getJavaVmSpecificationVendor

      public static @Nullable String getJavaVmSpecificationVendor()
      Returns:
      System property value java.vm.specification.vendor
    • getJavaVmSpecificationUrl

      public static @Nullable String getJavaVmSpecificationUrl()
      Returns:
      System property value java.vm.specification.url
    • getJavaVmVersion

      public static @Nullable String getJavaVmVersion()
      Returns:
      System property value java.vm.version
    • getJavaVmVendor

      public static @Nullable String getJavaVmVendor()
      Returns:
      System property value java.vm.vendor
    • getJavaVmUrl

      public static @Nullable String getJavaVmUrl()
      Returns:
      System property value java.vm.url
    • getJavaSpecificationVersion

      public static @Nullable String getJavaSpecificationVersion()
      Returns:
      System property value java.specification.version
    • getJavaSpecificationVendor

      public static @Nullable String getJavaSpecificationVendor()
      Returns:
      System property value java.specification.vendor
    • getJavaSpecificationUrl

      public static @Nullable 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") public static @Nullable String getTmpDir()
      Returns:
      System property value java.io.tmpdir
    • getJavaRuntimeVersion

      public static @Nullable String getJavaRuntimeVersion()
      Returns:
      System property value java.runtime.version
    • getJavaRuntimeName

      public static @Nullable String getJavaRuntimeName()
      Returns:
      System property value java.runtime.version
    • getAllProperties

      @ReturnsMutableCopy public static @NonNull NonBlockingProperties getAllProperties()
      Returns:
      A map with all system properties where the key is the system property name and the value is the system property value.
    • getAllPropertyNames

      @ReturnsMutableCopy public static @NonNull Set<String> getAllPropertyNames()
      Returns:
      A set with all defined property names. Never null.
    • 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

      @ReturnsMutableCopy public static @NonNull 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.