由于最近看Tomcat和GlassFish的源码,发现其启动脚本中有许多-D的参数,比如:
能够理解是设置一些属性,在运行时再获取,但为什么是-D一直没搞清,今天网上看到一个java -D的写法,才明白,原来是java运行参数,和-cp,-verbose这一类的差不多。
最终这些-D参数可以在代码中用
来获取。
ps:
- -Dcatalina.home="%CATALINA_HOME%"
- -Djava.io.tmpdir="%CATALINA_TMPDIR%"
能够理解是设置一些属性,在运行时再获取,但为什么是-D一直没搞清,今天网上看到一个java -D的写法,才明白,原来是java运行参数,和-cp,-verbose这一类的差不多。
最终这些-D参数可以在代码中用
- System.getProperty(catalina.home"); //-D后相应的参数
来获取。
![](http://chainhou.iteye.com/images/smiles/icon_biggrin.gif)
ps:
- where options include:
- -client to select the "client" VM
- -server to select the "server" VM
- -hotspot is a synonym for the "client" VM [deprecated]
- The default VM is client.
- -cp <class search path of directories and zip/jar files>
- -classpath <class search path of directories and zip/jar files>
- A ; separated list of directories, JAR archives,
- and ZIP archives to search for class files.
- -D<name>=<value>
- set a system property