在 Tomcat 中添加 JVM 选项
如何在 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
How can I add jvm(Java virtual machine) options in Apache Tomcat 6?
Is there a administration console in tomcat? I tried http://localhost:8080/admin but I could not get anything out of it.
I want to add the following jvm options:
-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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
正如 Bhavik Shah 所说,您可以在
JAVA_OPTS
中执行此操作,但推荐的方法(根据catalina.sh
)是使用CATALINA_OPTS
:As Bhavik Shah says, you can do it in
JAVA_OPTS
, but the recommended way (as percatalina.sh
) is to useCATALINA_OPTS
:将其设置在 [tomcat 路径]/bin/catalina.sh 中的
JAVA_OPTS
变量中。在 Windows 下有一个控制台,您可以在其中进行设置或使用 catalina.bat。Set it in the
JAVA_OPTS
variable in [path to tomcat]/bin/catalina.sh. Under windows there is a console where you can set it up or you use the catalina.bat.检查
catalina.sh
后(对于Windows,请使用下面提到的所有内容的.bat
版本)此外
,因此在CATALINA_BASE/下创建一个
setenv.sh
bin(与catalina.sh
所在的目录相同)。编辑文件并将参数设置为 CATALINA_OPTS例如,如果您想更改堆大小,文件将如下所示:
或者在您的情况下,因为您使用的是 Windows
setenv.bat< /code> 将是要
稍后清除添加的选项,只需删除
setenv.bat
或setenv.sh
。After checking
catalina.sh
(for windows use the.bat
versions of everything mentioned below)Also this
So create a
setenv.sh
under CATALINA_BASE/bin (same dir where thecatalina.sh
resides). Edit the file and set the arguments toCATALINA_OPTS
For e.g. the file would look like this if you wanted to change the heap size:
Or in your case since you're using windows
setenv.bat
would beTo clear the added options later just delete
setenv.bat
orsetenv.sh
.为此,您需要运行“tomcat6w”应用程序,该应用程序是“bin”目录中标准 Tomcat 发行版的一部分。例如,对于 Windows,默认值为“C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\tomcat6w.exe”。 “tomcat6w”应用程序启动 GUI。如果选择“Java”选项卡,您可以输入所有 Java 选项。
还可以通过命令行将 JVM 选项传递给 tomcat。为此,您需要使用以下命令:
其中“tomcatexecutable”指的是您的 tomcat 应用程序,“tomcatservicename”是您正在使用的 tomcat 服务名称,“JVMoptions”是您的 JVM 选项。例如:
For this you need to run the "tomcat6w" application that is part of the standard Tomcat distribution in the "bin" directory. E.g. for windows the default is "C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\tomcat6w.exe". The "tomcat6w" application starts a GUI. If you select the "Java" tab you can enter all Java options.
It is also possible to pass JVM options via the command line to tomcat. For this you need to use the command:
where "tomcatexecutable" refers to your tomcat application, "tomcatservicename" is the tomcat service name you are using and "JVMoptions" are your JVM options. For instance:
如果你想在 Eclipse 上设置 jvm 参数,你可以使用下面的方法:
参见下面的两个链接来完成它:
对于 Tomcat,您可以在 Tomcat 的 bin 文件夹中创建一个
setenv.bat
文件,并向其中添加以下行:if you want to set jvm args on eclipse you can use below:
see below two links to accomplish it:
And for Tomcat you can create a
setenv.bat
file in bin folder of Tomcat and add below lines to it :如果您从startup.bat启动tomcat,您需要添加一个系统变量:JAVA_OPTS作为名称和您想要的参数(在您的情况下:
-agentpath:C:\calltracer\jvmti\calltracer5.dll=traceFile-C:\calltracer\call.trace,filterFile-C:\calltracer\filters.txt,outputType-xml,使用不受控制
-Djava.library.path=C:\calltracer\jvmti -Dcalltracerlib=calltracer5
If you start tomcat from startup.bat, you need to add a system variable :JAVA_OPTS as name and the parameters that you wants (in your case :
-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
为了确保某些 Linux 发行版的完整性,您还可以检查文件
/etc/default/tomcat8
。该文件可以配置变量
JAVA_OPTS
:For sake of completeness in some linux distributions you could also check the file
/etc/default/tomcat8
.This file can configure a variable
JAVA_OPTS
:对于 Windows,在 %CATALINA_HOME%/bin 中创建(或编辑)文件 setenv.bat,其内容为:
对于 Linux,在 $CATALINA_HOME 中创建(或编辑)文件 setenv.sh /bin 内容:
我不建议修改主脚本(catalina.bat/.sh)。
For windows create(or edit) an file setenv.bat in %CATALINA_HOME%/bin with content:
For linux create(or edit) an file setenv.sh in $CATALINA_HOME/bin with content:
I don't recommend modifying the main script (catalina.bat/.sh).