Eclipse环境变量错误

时间:2015-09-14 14:04:06

标签: java eclipse

我正在使用Eclipse Mars,并且正在运行带有一些VM参数的应用程序,并且在运行配置中定义了环境变量

TOMCAT_HOME c:\tomcat

我在环境选项卡VM参数中有以下内容: -Dcatalina.home=${TOMCAT_HOME}

我收到以下错误:

Reference to undefined variable TOMCAT_HOME

为什么我在运行配置中指定变量,但它不能作为VM arg?

编辑:

原来,答案是您需要从 Window->偏好设置菜单中添加类路径变量。这令人困惑。

1 个答案:

答案 0 :(得分:2)

The Environment tab does not seem to work. Here is the way I could get this work:

  1. In the Run Configurations, on the Arguments tab, click on Variables in VM Arguments section. enter image description here
  2. Click on Edit Variables enter image description here
  3. Click on New, add Name and Value to the variable
  4. You can find the new variable added in the list. You can double-click on the item to add it to your VM Arguments pane. enter image description here
  5. I have used it as -Dcatalina.home=${TOMCAT_HOME} and I could access this value from System.getProperty("catalina.home")