CATALINA_OPTS vs JAVA_OPTS - What is the difference?
There are two environment variables - CATALINA_OPTS
and JAVA_OPTS
- which are both used in the catalina.sh
startup and shutdown script for Tomcat.
CATALINA_OPTS: Comment inside catalina.sh:
# CATALINA_OPTS (Optional) Java runtime options used when the "start",
# "run" or "debug" command is executed.
# Include here and not in JAVA_OPTS all options, that should
# only be used by Tomcat itself, not by the stop process,
# the version command etc.
# Examples are heap size, GC logging, JMX ports etc.
JAVA_OPTS: Comment inside catalina.sh:
# JAVA_OPTS (Optional) Java runtime options used when any command
# is executed.
# Include here and not in CATALINA_OPTS all options, that
# should be used by Tomcat and also by the stop process,
# the version command etc.
# Most options should go into CATALINA_OPTS.
So why are there two different variables? And what's the difference?
Firstly, anything specified in EITHER variable is passed, identically, to the command that starts up Tomcat - the
start
orrun
command - but only values set inJAVA_OPTS
are passed to thestop
command. That probably doesn't make any difference to how Tomcat runs in practice as it only effects the END of a run, not the start.The second difference is more subtle. Other applications may also use
JAVA_OPTS
, but only Tomcat will useCATALINA_OPTS
. So if you're setting environment variables for use only by Tomcat, you'll be best advised to useCATALINA_OPTS
, whereas if you're setting environment variables to be used by other java applications as well, such as by JBoss, you should put your settings inJAVA_OPTS
.
Source: CATALINA_OPTS v JAVA_OPTS - What is the difference?