views:

357

answers:

1

I am looking for a way to programmatically set Java Options for Tomcat 6.0 running as a Windows service. When using startup.bat and shutdown.bat, you can set these variables in a setenv.bat or catalina.bat file. However, for Tomcat running as a Windows Service, these options must be manually set in the Java Options section of the configuration utility.

Is there any way to programmatically set these options?

Background: I am trying to write an installer that will deploy my app to an existing Tomcat 6.0 server. I can do everything else programmatically, but I'll still have to ask the user to manually add a few Java Options in these settings. This is less than ideal, especially since these options are case- and whitespace-sensitive.

+2  A: 

The Tomcat6 binary for running Tomcat as a Windows service has a bunch of command-line parameters that will likely help you. The only issue I foresee is that it's hard (impossible?) to retrieve the current settings so that you can modify them...

delfuego
thanks, this is working: `tomcat6 //US//Tomcat6 --JvmOptions="-DSetting1=Value1;-DSetting2=Value2"` However, as you said, this is a problem because it overwrites all of the existing java options, and I don't want to overwrite the settings for other apps that may be on this server
Kip
I was thinking about this on my drive home; I bet you can find the original settings in the Windows registry, and then modify them (maybe even in the registry directly, but definitely using the `tomcat6 //US//` command line method as well). SO had a thread about reading the registry in Java: http://stackoverflow.com/questions/62289/read-write-to-windows-registry-using-java ; I think that the Tomcat service info should live at HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\Tomcat6\. Totally kludgy, but I don't know if there's another way.
delfuego
thanks, this helps a lot
Kip