CATALINA_OPTS与JAVA_OPTS - 有什么区别? [英] CATALINA_OPTS vs JAVA_OPTS - What is the difference?

查看:277
本文介绍了CATALINA_OPTS与JAVA_OPTS - 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 CATALINA_OPTS 和 JAVA_OPTS 之间的区别http://stackoverflow.comtitle =StackOverflow>所以并惊讶地发现此处尚未发布任何问题/答案。在找到差异后,我想在这里分享(有答案)。检查下面的答案/差异。

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.

注意:在发布这篇文章时,我们正在使用JDK 6u32运行Apache Tomcat v6.0.10在CentOS5 64位拱门上。

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 - 这些都在Tomcat的 catalina.sh 启动和关闭脚本中使用。它们在该文件中的注释中描述为:

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] :(可选)start时使用的Java运行时选项,停止或运行
命令被执行

[JAVA_OPTS]: (optional) Java runtime options used when the "start", "stop" or "run" command is executed

[CATALINA_OPTS] :(可选)执行start或run命令时使用的Java运行时选项

[CATALINA_OPTS]: (optional) Java runtime options used when the "start" or "run" command is executed

那么为什么有两个不同的变量呢?有什么区别?

首先,在EITHER变量中指定的任何内容都会以相同的方式传递给启动Tomcat的命令 - start或运行命令 - 但只有在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 - 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆