Search code examples
windowstomcat7

How to pass environment variable to Tomcat running as Windows service


I have an application installed in Tomcat that is invoked by the wrapper which sets an environment variable

set FOO=c:\foo

and invokes the startup.bat, and I have a requirement to run Tomcat as windows service.

So far, I tried to set the system environment variable, which did not help. I tried following the windows service HOWTO appending ++Environment in the registry, so that

 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tomcat7\Parameters\ImagePath 

looks like this

C:\Apache\Tomcat-7.0.64\bin\Tomcat7.exe //RS//Tomcat7 ++Environment=FOO=c:\foo

That did not help either.

Any suggestions, please


Solution

  • You were almost there. Replace the equal sign with a space in your tomcat7 command, and that should work.

    I've just written this up on another question: Setting User Environment Variables for tomcat on Windows