问题
I have a tomcat7 service running on windows, Usually in order to configure the Java options I go to Tomcat 7.0\bin\tomcat7w.exe and there in java tab, in java options I print the definition I want, for example -javaagent:... I want to do this through command line or using some script to have it automated, is there any way to achieve this and still run the tomcat as a service? (right now I run tomcat through cmd: "sc tomcat7 start").
Thanks
回答1:
See http://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html#Updating_services
You can run something like the following (the first "tomcat7.exe
" is the service executable name, and the second "//US//tomcat7
" is the service name prefixed with //US//
, meaning "update service"):
tomcat7.exe //US//tomcat7 "--JvmOptions=-Xrs;-javaagent:xyz"
The values passed with the --JvmOptions
flag are semicolon separated JAVA_OPTS
flags. If you do this while the service is not running, i.e. before you execute:
sc.exe tomcat7 start
then it will affect subsequent starts of that "tomcat7" Tomcat service.
来源:https://stackoverflow.com/questions/9193131/setting-java-opts-to-tomcat-service-from-command-line