Eclipse中Program arguments和VM arguments的说明

在运行程序的时候,我们一般可以进行run configuration的配置,就比如tomcat源码导入eclipse之后,我们可以发现其运行配置如下:

其中Program arguments配置的元素就是我们传入main方法的字符串数组,而VM arguments其实就是我们在程序中需要的运行时环境变量。比如上图中就是指定catalina.home为工程所在的位置。在程序中我们可以通过 System.getProperties("catalina.home")。需要注意的一点,上面的catalina.home的配置中用到了预置的${project_loc}变量(可以通过下面的Variables按钮进行添加),其实后面的部分可以省略不要,只是用来指定工程中的特定文件。对于${project_loc}的说明eclipse官网的描述如下:

The absolute path on the system's hard drive to the currently selected resource's project or to the project being built if the external tool is run as part of a build.

其实就是指的工程所在的绝对路径,比如我运行的这个代码所在的工程在 c:/workspace下,工程的名字为project1。那么此时${project_loc}就应该为:c:/workspace/project1。

具体的其他参数的说明请参照官方文档: http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fconcepts-exttools.htm

原文地址:https://www.cnblogs.com/Kidezyq/p/5832204.html