在 Tomcat 中添加 JVM 选项

发布于 2024-12-09 10:26:30 字数 430 浏览 0 评论 0原文

如何在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

固执像三岁 2024-12-16 10:26:30

正如 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.

As Bhavik Shah says, you can do it in JAVA_OPTS, but the recommended way (as per catalina.sh) is to use 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.
江心雾 2024-12-16 10:26:30

将其设置在 [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

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.

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
千柳 2024-12-16 10:26:30

检查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/下创建一个setenv.sh bin(与 catalina.sh 所在的目录相同)。编辑文件并将参数设置为 CATALINA_OPTS

例如,如果您想更改堆大小,文件将如下所示:

CATALINA_OPTS=-Xmx512m

或者在您的情况下,因为您使用的是 Windows setenv.bat< /code> 将是要

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.batsetenv.sh

After checking catalina.sh (for windows use the .bat versions of everything mentioned below)

#   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.

Also this

#   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

So create a setenv.sh under CATALINA_BASE/bin (same dir where the catalina.sh resides). Edit the file and set the arguments to CATALINA_OPTS

For e.g. the file would look like this if you wanted to change the heap size:

CATALINA_OPTS=-Xmx512m

Or in your case since you're using windows setenv.bat would be

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

To clear the added options later just delete setenv.bat or setenv.sh.

等待我真够勒 2024-12-16 10:26:30

为此,您需要运行“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" 

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:

<tomcatexecutable> //US//<tomcatservicename> ++JvmOptions="<JVMoptions>"

where "tomcatexecutable" refers to your tomcat application, "tomcatservicename" is the tomcat service name you are using and "JVMoptions" are your JVM options. For instance:

"tomcat6.exe" //US//tomcat6 ++JvmOptions="-XX:MaxPermSize=128m" 
一刻暧昧 2024-12-16 10:26:30

如果你想在 Eclipse 上设置 jvm 参数,你可以使用下面的方法:

参见下面的两个链接来完成它:

  1. eclipse 设置将 jvm 参数传递给 java
  2. eclipse 设置将 jvm 参数传递给 java 并添加到在 eclipse 上运行配置

对于 Tomcat,您可以在 Tomcat 的 bin 文件夹中创建一个 setenv.bat 文件,并向其中添加以下行:

echo "hello im starting setenv"
set CATALINA_OPTS=-DNLP.home=${NLP.home} -Dhostname=${hostname}

if you want to set jvm args on eclipse you can use below:

see below two links to accomplish it:

  1. eclipse setting to pass jvm args to java
  2. eclipse setting to pass jvm args to java and adding to run config on eclipse

And for Tomcat you can create a setenv.bat file in bin folder of Tomcat and add below lines to it :

echo "hello im starting setenv"
set CATALINA_OPTS=-DNLP.home=${NLP.home} -Dhostname=${hostname}
酒中人 2024-12-16 10:26:30

如果您从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

篱下浅笙歌 2024-12-16 10:26:30

为了确保某些 Linux 发行版的完整性,您还可以检查文件 /etc/default/tomcat8

该文件可以配置变量 JAVA_OPTS

JAVA_OPTS="-Xmx2G"
JAVA_OPTS="${JAVA_OPTS} -DmyProp=value"

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 :

JAVA_OPTS="-Xmx2G"
JAVA_OPTS="${JAVA_OPTS} -DmyProp=value"
孤凫 2024-12-16 10:26:30

对于 Windows,在 %CATALINA_HOME%/bin 中创建(或编辑)文件 setenv.bat,其内容为:

set CATALINA_OPTS=%CATALINA_OPTS% -Djava.net.preferIPv4Stack=true

对于 Linux,在 $CATALINA_HOME 中创建(或编辑)文件 setenv.sh /bin 内容:

export CATALINA_OPTS="$CATALINA_OPTS -Djava.net.preferIPv4Stack=true"

我不建议修改主脚本(catalina.bat/.sh)。

For windows create(or edit) an file setenv.bat in %CATALINA_HOME%/bin with content:

set CATALINA_OPTS=%CATALINA_OPTS% -Djava.net.preferIPv4Stack=true

For linux create(or edit) an file setenv.sh in $CATALINA_HOME/bin with content:

export CATALINA_OPTS="$CATALINA_OPTS -Djava.net.preferIPv4Stack=true"

I don't recommend modifying the main script (catalina.bat/.sh).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文