Why does Java use -D to indicate system properties?

那年仲夏 提交于 2019-12-19 05:17:22

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/5791714/why-does-java-use-d-to-indicate-system-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!