public static String getenv(String name)
Gets the value of the specified environment variable. An environment variable is a system-dependent external named value. If a security manager exists, its checkPermission method is called with a RuntimePermission("getenv."+name) permission. This may result in a SecurityException being thrown. If no exception is thrown the value of the variable name is returned.
System properties and environment variables are both conceptually mappings between names and values. Both mechanisms can be used to pass user-defined information to a Java process. Environment variables have a more global effect, because they are visible to all descendants of the process which defines them, not just the immediate Java subprocess. They can have subtly different semantics, such as case insensitivity, on different operating systems. For these reasons, environment variables are more likely to have unintended side effects. It is best to use system properties where possible. Environment variables should be used when a global effect is desired, or when an external system interface requires an environment variable (such as PATH).
On UNIX systems the alphabetic case of name is typically significant, while on Microsoft Windows systems it is typically not. For example, the expression
System.getenv("FOO").equals(System.getenv("foo")) is likely to be true on Microsoft Windows.
name - the name of the environment variable
the string value of the variable, or null if the variable is not defined in the system environment
NullPointerException - if name is null SecurityException - if a security manager exists and its checkPermission method doesn't allow access to the environment variable name See Also: getenv(), ProcessBuilder.environment()
public static Properties getProperties()
Determines the current system properties. First, if there is a security manager, its checkPropertiesAccess method is called with no arguments. This may result in a security exception.
The current set of system properties for use by the
getProperty(String) method is returned as a Properties object. If there is no current set of system properties, a set of system properties is first created and initialized. This set of system properties always includes values for the following keys:
Multiple paths in a system property value are separated by the path separator character of the platform.
Note that even if the security manager does not permit the
getProperties operation, it may choose to permit the
the system properties
SecurityException- if a security manager exists and its checkPropertiesAccess method doesn't allow access to the system properties.
setProperties(java.util.Properties), SecurityException,SecurityManager.checkPropertiesAccess(), Properties