Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Java use -D to indicate system properties?

Why is the flag that indicates a System property in Java -D? Surely there is some semantics to this letter choice, but I can't guess what it is.

like image 849
Eric Wilson Avatar asked Apr 26 '11 14:04

Eric Wilson


2 Answers

It is short for setting a system define.

"define" debug to yes

-Ddebug=yes

There is some historical context, as other compilers use similar flags. For example, gcc uses -D to set a preprocessor define.

gcc -D debug=yes test.c

will compile test.c with a preprocessing environment where the preprocessor variable debug is set to yes.

like image 110
Edwin Buck Avatar answered Oct 11 '22 13:10

Edwin Buck


"defines" properties. Properties aren't arguments, so you'd need a special identifier anyway.

like image 24
Joseph Ottinger Avatar answered Oct 11 '22 14:10

Joseph Ottinger