Reputation: 11723
According to the Oracle documentation, I can set system properties of a Java process on the command line with the following syntax:
-Dproperty=value
But what happens when I don't specify the value, i.e. when I omit the "equals value" part:
-Dproperty
What value will the system property be set to? true
? An empty string? Or any string with an undefined, implementation specific value?
Upvotes: 15
Views: 5334
Reputation: 136062
It will return an empty string. According to System.getProperty(String key) null is returned only if there is no property with that key. So if we define a propety with -D
it exists in the system
Upvotes: 10
Reputation: 11723
From simple trials with a Oracle HotSpot VM, I can see that system properties set on the command line without value get an empty string as value.
However this is only a partial answer to the question. A link to the some specification would be a better answer.
Upvotes: 4