Class SystemProperties

java.lang.Object
org.apache.commons.lang3.SystemProperties

public final class SystemProperties extends Object
Accesses current system property names and values.
Since:
3.13.0
  • Field Details

    • AWT_TOOLKIT

      public static final String AWT_TOOLKIT
      The System property name "awt.toolkit".
      See Also:
    • FILE_ENCODING

      public static final String FILE_ENCODING
      The System property name "file.encoding".
      See Also:
    • FILE_SEPARATOR

      public static final String FILE_SEPARATOR
      The System property name "file.separator".
      See Also:
    • JAVA_AWT_FONTS

      public static final String JAVA_AWT_FONTS
      The System property name "java.awt.fonts".
      See Also:
    • JAVA_AWT_GRAPHICSENV

      public static final String JAVA_AWT_GRAPHICSENV
      The System property name "java.awt.graphicsenv".
      See Also:
    • JAVA_AWT_HEADLESS

      public static final String JAVA_AWT_HEADLESS
      The System property name "java.awt.headless".
      See Also:
    • JAVA_AWT_PRINTERJOB

      public static final String JAVA_AWT_PRINTERJOB
      The System property name "java.awt.printerjob".
      See Also:
    • JAVA_CLASS_PATH

      public static final String JAVA_CLASS_PATH
      The System property name "java.class.path".
      See Also:
    • JAVA_CLASS_VERSION

      public static final String JAVA_CLASS_VERSION
      The System property name "java.class.version".
      See Also:
    • JAVA_COMPILER

      public static final String JAVA_COMPILER
      The System property name "java.compiler".
      See Also:
    • JAVA_ENDORSED_DIRS

      public static final String JAVA_ENDORSED_DIRS
      The System property name "java.endorsed.dirs".
      See Also:
    • JAVA_EXT_DIRS

      public static final String JAVA_EXT_DIRS
      The System property name "java.ext.dirs".
      See Also:
    • JAVA_HOME

      public static final String JAVA_HOME
      The System property name "java.home".
      See Also:
    • JAVA_IO_TMPDIR

      public static final String JAVA_IO_TMPDIR
      The System property name "java.io.tmpdir".
      See Also:
    • JAVA_LIBRARY_PATH

      public static final String JAVA_LIBRARY_PATH
      The System property name "java.library.path".
      See Also:
    • JAVA_LOCALE_PROVIDERS

      public static final String JAVA_LOCALE_PROVIDERS
      The System property name "java.locale.providers".
      See Also:
    • JAVA_RUNTIME_NAME

      public static final String JAVA_RUNTIME_NAME
      The System property name "java.runtime.name".
      See Also:
    • JAVA_RUNTIME_VERSION

      public static final String JAVA_RUNTIME_VERSION
      The System property name "java.runtime.version".
      See Also:
    • JAVA_SPECIFICATION_NAME

      public static final String JAVA_SPECIFICATION_NAME
      The System property name "java.specification.name".
      See Also:
    • JAVA_SPECIFICATION_VENDOR

      public static final String JAVA_SPECIFICATION_VENDOR
      The System property name "java.specification.vendor".
      See Also:
    • JAVA_SPECIFICATION_VERSION

      public static final String JAVA_SPECIFICATION_VERSION
      The System property name "java.specification.version".
      See Also:
    • JAVA_UTIL_PREFS_PREFERENCES_FACTORY

      public static final String JAVA_UTIL_PREFS_PREFERENCES_FACTORY
      The System property name "java.util.prefs.PreferencesFactory".
      See Also:
    • JAVA_VENDOR

      public static final String JAVA_VENDOR
      The System property name "java.vendor".
      See Also:
    • JAVA_VENDOR_URL

      public static final String JAVA_VENDOR_URL
      The System property name "java.vendor.url".
      See Also:
    • JAVA_VERSION

      public static final String JAVA_VERSION
      The System property name "java.version".
      See Also:
    • JAVA_VM_INFO

      public static final String JAVA_VM_INFO
      The System property name "java.vm.info".
      See Also:
    • JAVA_VM_NAME

      public static final String JAVA_VM_NAME
      The System property name "java.vm.name".
      See Also:
    • JAVA_VM_SPECIFICATION_NAME

      public static final String JAVA_VM_SPECIFICATION_NAME
      The System property name "java.vm.specification.name".
      See Also:
    • JAVA_VM_SPECIFICATION_VENDOR

      public static final String JAVA_VM_SPECIFICATION_VENDOR
      The System property name "java.vm.specification.vendor".
      See Also:
    • JAVA_VM_SPECIFICATION_VERSION

      public static final String JAVA_VM_SPECIFICATION_VERSION
      The System property name "java.vm.specification.version".
      See Also:
    • JAVA_VM_VENDOR

      public static final String JAVA_VM_VENDOR
      The System property name "java.vm.vendor".
      See Also:
    • JAVA_VM_VERSION

      public static final String JAVA_VM_VERSION
      The System property name "java.vm.version".
      See Also:
    • LINE_SEPARATOR

      public static final String LINE_SEPARATOR
      The System property name "line.separator".
      See Also:
    • OS_ARCH

      public static final String OS_ARCH
      The System property name "os.arch".
      See Also:
    • OS_NAME

      public static final String OS_NAME
      The System property name "os.name".
      See Also:
    • OS_VERSION

      public static final String OS_VERSION
      The System property name "os.version".
      See Also:
    • PATH_SEPARATOR

      public static final String PATH_SEPARATOR
      The System property name "path.separator".
      See Also:
    • USER_COUNTRY

      public static final String USER_COUNTRY
      The System property name "user.country".
      See Also:
    • USER_DIR

      public static final String USER_DIR
      The System property name "user.dir".
      See Also:
    • USER_HOME

      public static final String USER_HOME
      The System property name "user.home".
      See Also:
    • USER_LANGUAGE

      public static final String USER_LANGUAGE
      The System property name "user.language".
      See Also:
    • USER_NAME

      public static final String USER_NAME
      The System property name "user.name".
      See Also:
    • USER_REGION

      public static final String USER_REGION
      The System property name "user.region".
      See Also:
    • USER_TIMEZONE

      public static final String USER_TIMEZONE
      The System property name "user.timezone".
      See Also:
  • Constructor Details

    • SystemProperties

      public SystemProperties()
  • Method Details

    • getAwtToolkit

      public static String getAwtToolkit()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getBoolean

      public static boolean getBoolean(String key, BooleanSupplier defaultIfAbsent)
      Gets the current value for the property named key as an boolean.
      Parameters:
      key - The key
      defaultIfAbsent - The default value
      Returns:
      an boolean or defaultIfAbsent
    • getFileEncoding

      public static String getFileEncoding()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getFileSeparator

      public static String getFileSeparator()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getInt

      public static int getInt(String key, IntSupplier defaultIfAbsent)
      Gets the current value for the property named key as an int.
      Parameters:
      key - The key
      defaultIfAbsent - The default value
      Returns:
      an int or defaultIfAbsent
    • getJavaAwtFonts

      public static String getJavaAwtFonts()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaAwtGraphicsenv

      public static String getJavaAwtGraphicsenv()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaAwtHeadless

      public static String getJavaAwtHeadless()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaAwtPrinterjob

      public static String getJavaAwtPrinterjob()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaClassPath

      public static String getJavaClassPath()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaClassVersion

      public static String getJavaClassVersion()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaCompiler

      public static String getJavaCompiler()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaEndorsedDirs

      public static String getJavaEndorsedDirs()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaExtDirs

      public static String getJavaExtDirs()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaHome

      public static String getJavaHome()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaIoTmpdir

      public static String getJavaIoTmpdir()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaLibraryPath

      public static String getJavaLibraryPath()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaLocaleProviders

      public static String getJavaLocaleProviders()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Java 9 and above.

      Returns:
      the current value from the system properties map.
    • getJavaRuntimeName

      public static String getJavaRuntimeName()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaRuntimeVersion

      public static String getJavaRuntimeVersion()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaSpecificationName

      public static String getJavaSpecificationName()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaSpecificationVendor

      public static String getJavaSpecificationVendor()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaSpecificationVersion

      public static String getJavaSpecificationVersion()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaUtilPrefsPreferencesFactory

      public static String getJavaUtilPrefsPreferencesFactory()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaVendor

      public static String getJavaVendor()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaVendorUrl

      public static String getJavaVendorUrl()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaVersion

      public static String getJavaVersion()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaVmInfo

      public static String getJavaVmInfo()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaVmName

      public static String getJavaVmName()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaVmSpecificationName

      public static String getJavaVmSpecificationName()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaVmSpecificationVendor

      public static String getJavaVmSpecificationVendor()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaVmSpecificationVersion

      public static String getJavaVmSpecificationVersion()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaVmVendor

      public static String getJavaVmVendor()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getJavaVmVersion

      public static String getJavaVmVersion()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getLineSeparator

      public static String getLineSeparator()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getLong

      public static long getLong(String key, LongSupplier defaultIfAbsent)
      Gets the current value for the property named key as a long.
      Parameters:
      key - The key
      defaultIfAbsent - The default value
      Returns:
      a long or defaultIfAbsent
    • getOsArch

      public static String getOsArch()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getOsName

      public static String getOsName()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getOsVersion

      public static String getOsVersion()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getPathSeparator

      public static String getPathSeparator()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getProperty

      public static String getProperty(String property)
      Gets a System property, defaulting to null if the property cannot be read.

      If a SecurityException is caught, the return value is null.

      Parameters:
      property - the system property name
      Returns:
      the system property value or null if a security problem occurs
    • getProperty

      static String getProperty(String property, Supplier<String> defaultValue)
      Gets a System property, defaulting to null if the property cannot be read.

      If a SecurityException is caught, the return value is null.

      Parameters:
      property - the system property name.
      defaultValue - get this Supplier when the property is empty or throws SecurityException.
      Returns:
      the system property value or null if a security problem occurs
    • getUserCountry

      public static String getUserCountry()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getUserDir

      public static String getUserDir()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getUserHome

      public static String getUserHome()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getUserLanguage

      public static String getUserLanguage()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getUserName

      public static String getUserName()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.
    • getUserTimezone

      public static String getUserTimezone()
      Gets the current value from the system properties map.

      Returns null if the property cannot be read due to a SecurityException.

      Returns:
      the current value from the system properties map.