I'm trying to configure Java options passed into TomCat for a 3rd party application that I'm deploying. The instructions that the app provides are:
- Open the Tomcat configuration tool from the Windows menu at Start > All Programs > Apache Tomcat > Tomcat Configuration.
- Click Configure and select the Java tab.
- At the bottom of the Java Options field, enter the following:
-Dexample.license.directory="C:\Program Files\example"
- Stop and restart the application server.
However, I need to do this programmatically, so I'd like to know what config file these options can be set in. Using the GUI is impractical for deploying the app to other developers' environments.
(I'm using Tomcat 6.0 if that is relevant...)
If you're using Tomcat as a Windows service, you can adjust the JVM options by going to the bin dir and running:
Turn the service off before you do this and restart it when you finish.
I just did this for my own tomcat server and it handled it for me.
The best way is to use setenv.sh/setenv.bat. It isn't in the as-downloaded Tomcat. But if you look in catalina.sh/catalina.bat, there's a check for a file called setenv. If it's there, it's run. That's where you set JAVA_OPTS, CATALINA_OPTS, etc. We use it to set JAVA_HOME, JAVA_OPTS, CATALINA_OPTS and JPDA_ADDR.
For Tomcat6, this file can be deployed to your CATALINA_BASE directory where it will be run. For previous versions of Tomcat (5, 5.5 at least) it has to be in CATALINA_HOME.
Putting all your environment variables into this file is ideal because then you don't have to change the stock startup scripts.
You should be able to set the environment variable JAVA_OPTS.
In Linux, it would look like this
I'm not up on my Windows environment variables...I think you'd use
You can set JAVA_OPTS in $TOMCAT_HOME\bin\catalina.bat
Cheers
If Tomcat is set as a service, you'll need to do something like:
In the command line go to tomcat\bin tomcat6w.exe //ES //MYSERVICE
This will open a gui dialog box where you can make the settings.