Returns the Java system property indicated by the specified key.
public static String getProperty(String key,
String def)
Gets the system property indicated by the specified key. If there's no property with that key, the specified default value (def) is returned.
The difference between system properties and environment
variables is : properties are set for the currently running Java process, they are usually set as
-Dname=value while running a Java program. Whereas, Environmental variables are set on O.S. level e.g. path variable,
JAVA_HOME etc.
Examples
package com.logicbig.example.system;
public class GetPropertyExample {
public static void main(String... args) { String s = System.getProperty("java.io.tmpdir"); System.out.println(s);