Javatpoint Logo
Javatpoint Logo

Java System getProperty() Method

The getProperty(String key,Stringdef) method of Java System class returns property of a system which is indicated by a specified key.

Syntax

Parameter

key - the name of the system property.

def - a default value.

Returns

This method returns System property or default value if there is no property with that key.

Exception

  1. If key is null, a NullPointerException is thrown.
  2. If key is empty, aIllegarArgumentException is thrown.
  3. If Secutity manager exist and its CheckProperty method doesn't allow access to the specified system property, a SecurityException is thrown.

Example 1

Test it Now

Output:

my name : Shubham Jadon

Example 2

Test it Now

Output:

my name : null
Next TopicJava System



Help Others, Please Share

facebook twitter pinterest