This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Tomcat and the fly likes best place to put JAVA_OPTS setting for Tomcat memory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "best place to put JAVA_OPTS setting for Tomcat memory " Watch "best place to put JAVA_OPTS setting for Tomcat memory " New topic
Author

best place to put JAVA_OPTS setting for Tomcat memory

Charles Owen
Ranch Hand

Joined: Aug 31, 2009
Posts: 61
I am running Tomcat 6.0.24 on SuSE Linux. Where's the best place to put my JAVA_OPTS setting for setting the memory heap size?

Can someone give me an example? The idea is to set it somewhere before Tomcat starts, right?

I can see a few places to put it.

Tomcat6.conf
catalina.sh

I have no setenv.sh.

Thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

setenv.sh/setenv.bat are not supplied with Tomcat, but if you add one, Tomcat will use it. It's the best place to put stuff like that, since you totally own that file and don't have to modify any of Tomcat's own files, which can simplify maintenance and assist in intrusion detection (the original Tomcat files would retain their original text/checksum values).

If Tomcat (catalina) detects the presence of a setenv file, it will execute it to set up the environment to be used for the requested catalina operation. This file must have read access rights for the Tomcat user, and I recommend execute rights (where applicable) as well, although I don't think they're actually mandatory.


Customer surveys are for companies who didn't pay proper attention to begin with.
Charles Owen
Ranch Hand

Joined: Aug 31, 2009
Posts: 61
Thanks for your response. I will give this a whirl.

Charles Owen
Ranch Hand

Joined: Aug 31, 2009
Posts: 61
Actually I noticed that my tomcat start up script explicitly specifies tomcat6.conf as the configuration file, so I think I should put the JAVA_OPTS setting there. This may be a SuSE Linux convention.

# Get the tomcat config (use this for environment specific settings)
TOMCAT_CFG="/etc/tomcat6/tomcat6.conf"

When I set the JAVA_OPTS, do I also have to export it?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

SuSe is a lot like Red Hat, and although I usually install Tomcat as a straight UNZIP from tomcat.apache.org, I've also worked on occasion with RPM-based installs. Main reason I don't use RPM for Tomcat routinely is that there's not always an RPM available - especially for up-to-date releases of Tomcat.

What the RPM mostly does is make Tomcat friendlier to the Linux Filesystem Hierarchy Standard, which it does by the magic of softlinks so that Tomcat's logs appear in /var/logs, the temp appears in /var/lib, config appears in /etc, and so forth. Obviously your RPM does just a little bit more than that. I think that tomcat6.conf is actually sourced by an init script which is a third-party addition to the package (take a look at /etc/init.d/tomcat6).

conf files do not require exports. Aside from just being a general Unix/Linux rule, in this particular case, that's because the conf file will be sourced by the init script and then inherited by the catalina script that the init script invokes.
 
jQuery in Action, 2nd edition
 
subject: best place to put JAVA_OPTS setting for Tomcat memory
 
Similar Threads
java.lang.OutOfMemoryError: Java heap space
OutOfMemory with JSF RI, RichFaces, Faclets, and Tomcat
Out of Memory Issues with Tomcat on Ubuntu 10
Keystore was tampered with, or password was incorrect
Is this writting for JAVA_OPTS correct?