When the Java system property is set on the command line without a value ("-Dkey"), what value does it get?

According to the Oracle documentation, I can set the system properties of the Java process on the command line with the following syntax:

-Dproperty=value 

But what happens when I do not specify a value, i.e. when I omit the equal value part:

 -Dproperty 

What value will be assigned to the system property? true ? Empty line? Or any string with undefined, specific implementation value?

+7
java command-line
source share
2 answers

It will return an empty string. According to System.getProperty (String key), null is returned only if there is no property with this key. Therefore, if we define propety with -D , it exists in the system

+5
source share

From simple tests with VMware Oracle HotSpot, I see that the system properties set on the command line without a value get the empty string value as the value.

However, this is only a partial answer to the question. A better answer would be a link to some specifications.

0
source share

All Articles