I was trying to find out the difference between Apache Tomcat variables - CATALINA_OPTS
and JAVA_OPTS
in SO and surprised to see that there is no question/answer posted here yet. So I thought of sharing it here (with answer) after finding out the difference. Check the answer/difference below.
我试图在SO中找出Apache Tomcat变量 - CATALINA_OPTS和JAVA_OPTS之间的区别,并惊讶地发现这里没有问题/答案。在找到差异后,我想在这里分享(有答案)。检查下面的答案/差异。
NOTE: At the time of this posting, we're running Apache Tomcat v6.0.10 with JDK 6u32 on CentOS5 64-bit arch.
注意:在发布时,我们在CentOS5 64位arch上运行带有JDK 6u32的Apache Tomcat v6.0.10。
1 个解决方案
#1
122
There are two environment variables - CATALINA_OPTS
and JAVA_OPTS
- which are both used in the catalina.sh startup and shutdown script for Tomcat. They are described in comments within that file as:
有两个环境变量 - CATALINA_OPTS和JAVA_OPTS - 它们都在Tomcat的catalina.sh启动和关闭脚本中使用。它们在该文件中的注释中描述为:
[JAVA_OPTS]: (optional) Java runtime options used when the "start", "stop" or "run" command is executed
[JAVA_OPTS] :(可选)执行“start”,“stop”或“run”命令时使用的Java运行时选项
and
和
[CATALINA_OPTS]: (optional) Java runtime options used when the "start" or "run" command is executed
[CATALINA_OPTS] :(可选)执行“start”或“run”命令时使用的Java运行时选项
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" or "run" command - but only values set in JAVA_OPTS are passed to the "stop" command. That probably doesn't make any difference to how Tomcat runs in practise as it only effects the end of a run, not the start.
首先,在EITHER变量中指定的任何内容都以相同的方式传递给启动Tomcat的命令 - “start”或“run”命令 - 但只有在JAVA_OPTS中设置的值才会传递给“stop”命令。这可能对Tomcat在实践中的运行方式没有任何影响,因为它只影响运行的结束,而不是开始。
The second difference is more subtle. Other applications may also use JAVA_OPTS, but only Tomcat will use CATALINA_OPTS. So if you're setting environment variables for use only by Tomcat, you'll be best advised to use CATALINA_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 in JAVA_OPTS.
第二个区别更微妙。其他应用程序也可以使用JAVA_OPTS,但只有Tomcat才会使用CATALINA_OPTS。因此,如果您设置的环境变量仅供Tomcat使用,那么最好建议您使用CATALINA_OPTS,而如果您正在设置环境变量以供其他Java应用程序使用,例如JBoss,您应该放置您在JAVA_OPTS中的设置。
Source: CATALINA_OPTS v JAVA_OPTS - What is the difference?
来源:CATALINA_OPTS v JAVA_OPTS - 有什么区别?
#1
122
There are two environment variables - CATALINA_OPTS
and JAVA_OPTS
- which are both used in the catalina.sh startup and shutdown script for Tomcat. They are described in comments within that file as:
有两个环境变量 - CATALINA_OPTS和JAVA_OPTS - 它们都在Tomcat的catalina.sh启动和关闭脚本中使用。它们在该文件中的注释中描述为:
[JAVA_OPTS]: (optional) Java runtime options used when the "start", "stop" or "run" command is executed
[JAVA_OPTS] :(可选)执行“start”,“stop”或“run”命令时使用的Java运行时选项
and
和
[CATALINA_OPTS]: (optional) Java runtime options used when the "start" or "run" command is executed
[CATALINA_OPTS] :(可选)执行“start”或“run”命令时使用的Java运行时选项
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" or "run" command - but only values set in JAVA_OPTS are passed to the "stop" command. That probably doesn't make any difference to how Tomcat runs in practise as it only effects the end of a run, not the start.
首先,在EITHER变量中指定的任何内容都以相同的方式传递给启动Tomcat的命令 - “start”或“run”命令 - 但只有在JAVA_OPTS中设置的值才会传递给“stop”命令。这可能对Tomcat在实践中的运行方式没有任何影响,因为它只影响运行的结束,而不是开始。
The second difference is more subtle. Other applications may also use JAVA_OPTS, but only Tomcat will use CATALINA_OPTS. So if you're setting environment variables for use only by Tomcat, you'll be best advised to use CATALINA_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 in JAVA_OPTS.
第二个区别更微妙。其他应用程序也可以使用JAVA_OPTS,但只有Tomcat才会使用CATALINA_OPTS。因此,如果您设置的环境变量仅供Tomcat使用,那么最好建议您使用CATALINA_OPTS,而如果您正在设置环境变量以供其他Java应用程序使用,例如JBoss,您应该放置您在JAVA_OPTS中的设置。
Source: CATALINA_OPTS v JAVA_OPTS - What is the difference?
来源:CATALINA_OPTS v JAVA_OPTS - 有什么区别?