Setting java_opts to tomcat service from command line

六眼飞鱼酱① 提交于 2019-12-10 22:41:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!