how to set JAVA_OPTS for Tomcat in Windows?

后端 未结 7 2192
别跟我提以往
别跟我提以往 2020-12-09 16:13

I\'m trying to set JAVA_OPTS for Tomcat on a Windows machine, but I keep getting an error if I add more than one variable.

For example, this works:

7条回答
  •  不知归路
    2020-12-09 16:52

    I like a combination of Gaurav's and user2550946's answer best, but would like to add two more aspects:

    1. Don't use JAVA_OPTS, instead use CATALINA_OPTS. This will be used solely for starting tomcat, not for shutting it down. Typically you want more memory when starting tomcat, but the shutdown process (which just spins up, tells tomcat to shut down and then ends again) doesn't need any specifically tuned resources. In fact, shutdown can even fail if some ridiculous amount of memory is not available from the OS anymore.

    2. On production systems, my recommentation is to claim the maximum allowed memory immediately. Because if you anticipate that the memory will be required sooner or later, you don't want to discover it not being available at 3am in the night - rather when you start up the server. Thus, set -Xmx and -Xms to the same value in production systems. (This makes my aspect 1 even more relevant)

    Or, in one line, here's my recommendation:

    set "CATALINA_OPTS=%CATALINA_OPTS% -Xms1024M -Xmx1024M"
    

提交回复
热议问题