Where to set java heap options (e.g. -Xmx) for Tomcat 6 under Ubuntu 9.04?

At least on Ubuntu 10.04, /etc/init.d/tomcat6 sources /etc/default/tomcat6 if it exists. That's where I put my overrides, and I believe it's generally the "approved" way to make such changes.


If you look in your installation's bin directory you will see catalina.sh or .bat scripts. If you look in these you will see that they run a setenv.sh or setenv.bat script respectively, if it exists, to set environment variables. The relevant environment variables are described in the comments at the top of catalina.sh/bat. To use them create, for example, a file $CATALINA_HOME/bin/setenv.sh with contents

export JAVA_OPTS="-server -Xmx512m"

For Windows you will need, in setenv.bat, something like

set JAVA_OPTS=-server -Xmx768m

This is true from tomcat 5.5 through 7. Original answear https://stackoverflow.com/questions/286007/how-to-tune-tomcat-5-5-jvm-memory-settings-without-using-the-configuration-progra


Look for /etc/tomcat6/tomcat6.conf which has the likes of JAVA_OPTS ready and waiting for you to uncomment (but only if you have it at all, I'm using Centos not Ubuntu).

# System-wide configuration file for tomcat6 services
# This will be sourced by tomcat6 and any secondary service
# Values will be overridden by service-specific configuration
# files in /etc/sysconfig
#
# Use this one to change default values for all services
# Change the service specific ones to affect only one service
# (see, for instance, /etc/sysconfig/tomcat6)
#
...
#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"