2

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

  • I can achieve that with using an out-of-box tomcat
  • I can also achieve that with a tomcat service installation through using the gui which is tomcat7w.exe.

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)?

max
  • 9,708
  • 15
  • 89
  • 144

2 Answers2

2

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.

max
  • 9,708
  • 15
  • 89
  • 144
1

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

Community
  • 1
  • 1
yuyang
  • 1,511
  • 2
  • 15
  • 40
  • Thanks. I have already tried that as well. Setting the variable in the windows environment windows under the public section is the same as using setx. The problem is that tomcat installed as a service does not look at the environment variable. – max Jul 04 '14 at 15:43