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

command-line, java

Solution

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

Problem

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?

Original source