max
max

Reputation: 10444

tomcat installed as service - how to set JAVA_OPTS non-interactively

I am trying to add an option to the JAVA_OPTS on a windows tomcat installed as a service.

However, I need to do it non-interactively for automation purposes. I tried putting

SET JAVA_OPTS=%JAVA_OPTS% -javaagent:C:\MY_DIR

in setenv.bat and in catalina.bat under bin folder; it did not work. I also tried setting an environment variable 'JAVA_OPTS' and starting tomcat from a new terminal; still that did not work. Q: is there a way to specify JAVA_OPTS with tomcat service non-interactively (without gui)?

Upvotes: 2

Views: 1619

Answers (2)

max
max

Reputation: 10444

I got a solution. I was able to add JAVA_OPTS to the Options registry key which on windows server 2008 is at: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\Tomcat7\Parameters\Java

to make tomcat see it. On other platforms might be a different path...but this is the best I could come up with.

Upvotes: 2

yuyang
yuyang

Reputation: 1651

On Windows, you can use 'setx' to set the environment variable.

http://ss64.com/nt/setx.html

Here is another stackoverflow thread that discussed the usage of setx:

How do I add to the Windows PATH variable using setx? Having weird problems

Upvotes: 1

Related Questions