如何通过 .bat 启动 tomcat 并添加 JAVA_OPTS

How can I start tomcat by .bat and add JAVA_OPTS

set JAVA_HOME=
echo deploy web service ......
set CATALINA_HOME=%WEBTIER_HOME%
call "%CATALINA_HOME%\bin\service.bat" install %webtier%
"%CATALINA_HOME%\bin\tomcat7.exe" //US//%webtier% ++JvmOptions "-Djava.library.path=%installdir%\bin;-XX:MaxPermSize=256M;-Xms256m;-Xmx1024M"
set CATALINA_HOME=%WEBSERVICE_HOME%
call "%CATALINA_HOME%\bin\service.bat" install %webservice%
"%CATALINA_HOME%\bin\tomcat7.exe" //US//%webservice% ++JvmOptions "-Djava.library.path=%installdir%\bin;-XX:MaxPermSize=256M;-Xms256m;-Xmx1024M"

这是启动java web服务的.bat文件,但是有内存泄漏和堆的错误,所以我想设置JAVA_OPTS,我可以直接添加"set JAVA_OPTS=-server -Xmx1024m"喜欢

set JAVA_HOME=
set JAVA_OPTS=-server -Xmx1024m
echo deploy web service ......
set CATALINA_HOME=%WEBTIER_HOME%
call "%CATALINA_HOME%\bin\service.bat" install %webtier%
"%CATALINA_HOME%\bin\tomcat7.exe" //US//%webtier% ++JvmOptions "-Djava.library.path=%installdir%\bin;-XX:MaxPermSize=256M;-Xms256m;-Xmx1024M"
set CATALINA_HOME=%WEBSERVICE_HOME%
call "%CATALINA_HOME%\bin\service.bat" install %webservice%
"%CATALINA_HOME%\bin\tomcat7.exe" //US//%webservice% ++JvmOptions "-Djava.library.path=%installdir%\bin;-XX:MaxPermSize=256M;-Xms256m;-Xmx1024M"

或者在-Djava.library.path之后添加作为JvmOptions参数

服务器将 JAVA_OPTS 环境变量附加到执行 java 命令的调用中。 因此,您需要在调用语句之前设置 JAVA_OPTS 即

set JAVA_OPTS=-Xms512M -Xmx1024M

call "%CATALINA_HOME%\bin\service.bat" install %webtier%"%CATALINA_HOME%\bin\tomcat7.exe" //US//%webtier% ++JvmOptions "-Djava.library.path=%installdir%\bin;-XX:MaxPermSize=256M;-Xms256m;-Xmx1024M"