Setting java_opts to tomcat service from command line
Asked Answered
C

1

3

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

Clypeus answered 8/2, 2012 at 12:15 Comment(1)
Tomcat has a configuration UI. See details:Tomcat deployment configuration as serviceOran
D
4

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.

Difference answered 13/12, 2012 at 15:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.