0

I'm using Eclipse Mars, and am running an application with some VM arguments and have environment variables defined on the run configuration

TOMCAT_HOME c:\tomcat

I have the following in the Environment tab VM arguments: -Dcatalina.home=${TOMCAT_HOME}

I get the following error:

Reference to undefined variable TOMCAT_HOME

How come I am specifying the variable in the run configuration but it is not working as a VM arg?

Edit:

Turns out that the answer is that you need to add a Classpath Variable from Window->Preferences menu. That's confusing.

mikeb
  • 10,578
  • 7
  • 62
  • 120
  • http://stackoverflow.com/questions/14026558/when-to-use-environment-variables-vs-system-properties – Pat B Sep 14 '15 at 14:11
  • @mikeb you must specify the variable to run the app on _Run Configuration Window_ to do it, so go to Run as... and put this new variable on _arguments tabs_ see the link https://www.eclipse.org/forums/index.php/t/6039/ – e2a Sep 14 '15 at 14:21

1 Answers1

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")
James Jithin
  • 10,183
  • 5
  • 36
  • 51