Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 829
PassoGiau Avatar asked Oct 21 '25 02:10

PassoGiau


2 Answers

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

like image 173
hktegner Avatar answered Oct 23 '25 16:10

hktegner


I had to change --JvmOptions of the service.bat file then remove the service and re-install again.

--JvmOptions "-Dspring.profiles.active=pp;-Dcatalina.home=%CATALINA_HOME%;...."
like image 44
Subhas Avatar answered Oct 23 '25 16:10

Subhas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!