Meaningless Drivel is fun!*
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
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: 16065
    
  21

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: 16065
    
  21

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: best place to put JAVA_OPTS setting for Tomcat memory