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

user1197126
  • 61
  • 1
  • 4
  • Tomcat has a configuration UI. See details:[Tomcat deployment configuration as service](https://stackoverflow.com/questions/21530484) – user2291296 May 30 '18 at 06:27

1 Answers1

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.

jacoz
  • 3,508
  • 5
  • 26
  • 42
David Conneely
  • 896
  • 6
  • 9