What does the D in
-Dproperty=value
Set a system property value.
of the java application launcher stand for? For some reason it\'s been
In C/C++ compilers the similar syntax is used to define preprocessor macros from the command line:
#include
int main(int argc, char* argv[]) {
printf(GREETING);
return 0;
}
.
gcc hello.c -DGREETING="\"Hello, world\""
Java doesn't have a preprocessor, but properties defined with -D
are ofter used for the similar reason - to pass some program-specific information about the current environment. The only difference is that in Java we pass them in runtime, not in compile-time:
public class Hello {
public static void main(String[] args) {
System.out.println(System.getProperty("greeting"));
}
}
.
java -Dgreeting="Hello, world" Hello
I think this similarity is the source of similar syntax.