Why does Java use -D to indicate system properties

2019-02-16 11:23发布

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.

2条回答
等我变得足够好
2楼-- · 2019-02-16 11:42

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

查看更多
啃猪蹄的小仙女
3楼-- · 2019-02-16 11:53

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.

查看更多
登录 后发表回答