Java System getProperties() Method
Example
Get all system properties, and check which property names they contain:
import java.util.Properties;
public class Main {
public static void main(String[] args) {
Properties props = System.getProperties();
System.out.println(props.containsKey("java.version"));
System.out.println(props.containsKey("os.name"));
System.out.println(props.containsKey("app.color"));
}
}
Definition and Usage
The getProperties() method returns all system properties in one Properties object. A Properties object is a map (a list of names and values), where both the names and the values are text.
Use the getProperty() method of the object to read one value.
Tip: Use System.getProperty() to read the value of one property directly.
Syntax
public static Properties getProperties()
Parameter Values
None.
Technical Details
| Returns: | A Properties object with all the system properties. |
|---|
Related Pages
❮ System Methods