Reputation: 9935
I have a crazy request about restarting tomcat server through my webapp. I was searching for nearly 2 days about this and all i found are executing external batch file or calling another program to do it. Is there any optimal solution for this by using java code? Am i missing something?
Upvotes: 3
Views: 3235
Reputation: 29824
Best solution we have found is to use the Java Service Wrapper
It provides multiple benefits in managing the lifecyle of your server - including what you are trying to achieve - and in particular the ability to easily register as a Windows service.
Upvotes: 0
Reputation: 2427
You can connect to the shutdown port tomcat opens and issue the shutdown command.
See http://tomcat.apache.org/tomcat-7.0-doc/config/server.html
Upvotes: 2
Reputation: 7197
Why not just create a script an call it trough Runtime.exec? Seems quite optimal to me. Since restarting tomcat will terminate the Java VM, it doesn't really make sense to have it as an API call.
Upvotes: 4