Add JVM options in Tomcat

后端 未结 6 470
失恋的感觉
失恋的感觉 2020-11-27 18:40

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

相关标签:
6条回答
  • 2020-11-27 18:46

    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" 
    
    0 讨论(0)
  • 2020-11-27 18:56

    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

    0 讨论(0)
  • 2020-11-27 19:04

    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.
    
    0 讨论(0)
  • 2020-11-27 19:04

    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}
    
    0 讨论(0)
  • 2020-11-27 19:08

    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/sh

    0 讨论(0)
  • 2020-11-27 19:10

    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
    
    0 讨论(0)
提交回复
热议问题