CATALINA_OPTS与JAVA_OPTS的区别

vm参数设置问题

Posted by Spencer on January 22, 2018

vm参数设置CATALINA_OPTS与JAVA_OPTS的区别

IDE里配置tomcat8.5.24启动失败

tomcat catalina.sh里设置了

export JAVA_OPTS="-server -Xms2g -Xmx2g -Xmn1g -Xss512K -XX:MetaspaceSize=512m 
 -XX:MaxMetaspaceSize=1g -XX:MaxDirectMemorySize=512M"

把设置的JAVA_OPTS参数注释掉,启动正常。但是为什么呢?

我们来看下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       (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.

然后又在网络查询是否有同样遇到这个问题。

找到了https://www.zhihu.com/question/35626538#answer-21186674/,其中R大还解释了另外2个环境变量参数以及优先级。

推荐R大 https://www.zhihu.com/people/rednaxelafx/activities/

–EOF–


本文链接:CATALINA_OPTS与JAVA_OPTS的区别
作者: Spencer
出处: https://spencerzhang.github.io
本文基于 知识共享署名-相同方式共享 4.0 国际许可协议发布,欢迎转载,演绎或用于商业目的,但是必须保留本文的署名 Spencer及链接。