Reputation: 377
I looked at this post,and they said to use a batch script to restart a tomcat server using a webapp. The issue is that if you use Runtime.exec("batch.bat"), once you do the kill for the tomcat server, the server dies and the runtime dies.
I did a quick test of this by adding some prints to my batch file to be sure:
echo "lol" > file1.txt
net stop tomcatservice
echo "lol2" > file2.txt
net start tomcatservice
echo "lol3" > file3.txt
Only file1 was created as suspected.
Is there a way to do what I want? Is there a way for me to restart the tomcat server on a schedule through code in my webapp?
Upvotes: 0
Views: 1325
Reputation: 8624
Use Runtime.exec("cmd /c start batch.bat")
it starts a new process so it wont be terminated when the server stops.
Upvotes: 1
Reputation: 68715
Create a batch file and write shutdown.bat followed by startup.bat. Call that batch file from your java code using Runtime. It should do the trick for you.
Upvotes: 1