如何在Apache Tomcat 6中添加jvm(Java虚拟机)选项?
tomcat中是否有管理控制台?我试过http://localhost:8080/admin,但我无法从中得到任何东西。
我想添加以下jvm选项:
-agentpath:C:\calltracer\jvmti\calltracer5.dll=traceFile-C:\calltracer\call.trace,filterFile-C:\calltracer\filters.txt,outputType-xml,usage-uncontrolled -Djava.library.path=C:\calltracer\jvmti -Dcalltracerlib=calltracer5
正如Bhavik Shah所说,你可以在JAVA_OPTS中做到这一点,但推荐的方法(根据catalina.sh)是使用CATALINA_OPTS:
# 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.
将它设置在[tomcat] /bin/catalina.sh的路径中的JAVA_OPTS
变量中。在Windows下有一个控制台,您可以在其中设置它或使用catalina.bat。
JAVA_OPTS=-agentpath:C:\calltracer\jvmti\calltracer5.dll=traceFile-C:\calltracer\call.trace,filterFile-C:\calltracer\filters.txt,outputType-xml,usage-uncontrolled -Djava.library.path=C:\calltracer\jvmti -Dcalltracerlib=calltracer5
为此,您需要运行“tomcat6w”应用程序,该应用程序是“bin”目录中标准Tomcat分发的一部分。例如。对于Windows,默认为“C:\ Program Files \ Apache Software Foundation \ Tomcat 6.0 \ bin \ tomcat6w.exe”。 “tomcat6w”应用程序启动GUI。如果选择“Java”选项卡,则可以输入所有Java选项。
也可以通过命令行将JVM选项传递给tomcat。为此,您需要使用以下命令:
<tomcatexecutable> //US//<tomcatservicename> ++JvmOptions="<JVMoptions>"
其中“tomcatexecutable”指的是tomcat应用程序,“tomcatservicename”是您正在使用的tomcat服务名称,“JVMoptions”是您的JVM选项。例如:
"tomcat6.exe" //US//tomcat6 ++JvmOptions="-XX:MaxPermSize=128m"
检查catalina.sh后(对于windows使用下面提到的所有内容的.bat版本)
# Do not set the variables in this script. Instead put them into a script
# setenv.sh in CATALINA_BASE/bin to keep your customizations separate.
还有这个
# 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
因此,在CATALINA_BASE / bin下创建一个setenv.sh(catalina.sh所在的dir)。编辑文件并将参数设置为CATALINA_OPTS
对于例如如果要更改堆大小,文件将如下所示
CATALINA_OPTS=-Xmx512m
或者在你的情况下,因为你正在使用windows setenv.bat
set CATALINA_OPTS=-agentpath:C:\calltracer\jvmti\calltracer5.dll=traceFile-C:\calltracer\call.trace,filterFile-C:\calltracer\filters.txt,outputType-xml,usage-uncontrolled -Djava.library.path=C:\calltracer\jvmti -Dcalltracerlib=calltracer5
要稍后清除添加的选项,只需删除setenv.bat / sh
如果你想在eclipse上设置jvm args你可以使用下面的代码:
看下面两个链接来完成它:
对于Tomcat,您可以在Tomcat的bin文件夹中创建一个setenv.bat
文件,并在其下面添加以下行:
echo "hello im starting setenv"
set CATALINA_OPTS=-DNLP.home=${NLP.home} -Dhostname=${hostname}
如果从startup.bat启动tomcat,则需要添加一个系统变量:JAVA_OPTS作为名称和您想要的参数(在您的情况下:
-agentpath:C:\ calltracer \ jvmti \ calltracer5.dll = traceFile-C:\ calltracer \ call.trace,filterFile-C:\ calltracer \ filters.txt,outputType-xml,usage-uncontrolled -Djava.library.path = C:\ calltracer \ jvmti -Dcalltracerlib = calltracer5