CATALINA_OPTS vs JAVA_OPTS - What is the difference?(CATALINA_OPTS 与 JAVA_OPTS - 有什么区别?)
问题描述
我试图找出 Apache Tomcat 变量之间的区别 - CATALINA_OPTS 和 JAVA_OPTS
StackOverflow">SO 惊讶地发现这里还没有发布任何问题/答案.所以我想在发现差异后在这里分享它(有答案).检查下面的答案/差异.
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.
注意:在发布本文时,我们在 CentOS5 64 位架构上运行 Apache Tomcat v6.0.10 和 JDK 6u32.
NOTE: At the time of this posting, we're running Apache Tomcat v6.0.10 with JDK 6u32 on CentOS5 64-bit arch.
推荐答案
有两个环境变量 - CATALINA_OPTS
和 JAVA_OPTS
- 在 catalina.sh Tomcat 的启动和关闭脚本.它们在该文件的注释中被描述为:
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:
[JAVA_OPTS]:(可选)开始"、停止"或运行"时使用的 Java 运行时选项命令被执行
[JAVA_OPTS]: (optional) Java runtime options used when the "start", "stop" or "run" command is executed
和
[CATALINA_OPTS]:(可选)Java 运行时选项执行start"或run"命令时使用
[CATALINA_OPTS]: (optional) Java runtime options used when the "start" or "run" command is executed
那么为什么会有两个不同的变量呢?又有什么区别?
首先,在 EITHER 变量中指定的任何内容都被传递给启动 Tomcat 的命令——start"或run"命令——但只有 JAVA_OPTS 中设置的值被传递给stop"命令.这可能对 Tomcat 在实践中的运行方式没有任何影响,因为它只影响运行的结束,而不是开始.
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.
第二个区别更微妙.其他应用程序也可能使用 JAVA_OPTS,但只有 Tomcat 会使用 CATALINA_OPTS.因此,如果您设置的环境变量仅供 Tomcat 使用,则最好使用 CATALINA_OPTS,而如果您设置的环境变量也可供其他 java 应用程序使用,例如 JBoss,您应该将您在 JAVA_OPTS 中的设置.
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.
来源: CATALINA_OPTS v JAVA_OPTS - 有什么区别?
这篇关于CATALINA_OPTS 与 JAVA_OPTS - 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:CATALINA_OPTS 与 JAVA_OPTS - 有什么区别?


- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01