How to set Catalina options in Ubuntu 12.10

This is more of a personal note and a really specific topic. This tutorial assumes you are using Ubuntu 12.10 or Ubuntu 12.04 and installed tomcat7 package. If you haven’t already installed tomcat7, use:

sudo apt-get install tomcat7

After doing so, create and edit the file setenv.sh. Putting setenv.sh in CATALINA_BASE/bin allows you to keep your customizations separate.

sudo nano /usr/share/tomcat7/bin/setenv.sh

I set my environment variables (in my case) as in setenv.sh:

CATALINA_OPTS="$CATALINA_OPTS -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m"

If the file is present, catalina.sh will pick it up and add to the runtime parameters.

To restart tomcat7, use:

sudo service tomcat7 restart

Verifying that it works

After the server restart, run this to check:

ps aux|grep jar

This should return:

tomcat7  14140 63.8 11.4 4001076 918296 ?      Sl   12:26   1:37 /usr/lib/jvm/default-java/bin/java -Djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.properties -Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m -Djava.endorsed.dirs=/usr/share/tomcat7/endorsed -classpath /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/var/lib/tomcat7 -Dcatalina.home=/usr/share/tomcat7 -Djava.io.tmpdir=/tmp/tomcat7-tomcat7-tmp org.apache.catalina.startup.Bootstrap start
kahwee   15564  0.0  0.0  13580   936 pts/1    S+   12:29   0:00 grep jar

You should be able spot your line of customization. And that’s the proper way to setting up Catalina options. You can also set JAVA_OPTS through this method too.

2 thoughts on “How to set Catalina options in Ubuntu 12.10”

  1. Do you know how to create setenv.sh for each webapps for example, I have 2 java version and 2 webapps

    # This Java is supported by one webapp “host1″
    $ ./java -version
    java version “1.7.0_45″
    OpenJDK Runtime Environment (rhel-2.4.3.3.el6-x86_64 u45-b15)
    OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

    # This Java supports another webapp “host2″, but does not support above
    webapp “host1″
    $ ./java -version
    java version “1.7.0_45″
    Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
    Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

    Any help will be appreciated.

    -Peter

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>