Javatpoint Logo
Javatpoint Logo

Java System setProperty() Method

The setProperty() method of Java system class sets the property of the system which is indicated by a key.

Syntax:

Parameters:

key - It is the name of the system property.

value - It is the value of the system property.

Returns

This method returns the System property's previous value. If System Property does not have any previous value, this method returns null.

Exceptions

  • SecurityException is thrown if security manager exists and its checkPermission method doesn't allow setting of the specified property.
  • NullPointerException is thrown key or value is null.
  • IllegalArgumentException is thrown if the key is empty.

Example

Test it Now

Output:

Pervious property : {name=Shubham Jadon}
New property : {name=Jadon Shubham}

Next TopicJava System




Help Others, Please Share

facebook twitter pinterest