title: how to restart tomcat from a running webapp?
body: <p>I need to restart tomcat service from a webapp running on this tomcat. So I'm trying to execute script that stops tomcat service, and then starts it:</p>
  
  <pre><code>echo "before stop" &gt;&gt; textfile.txt
  NET STOP "Tomcat7"
  
  :loop
      timeout 3
      SC query Tomcat7 | FIND "STATE" | FIND "RUNNING" &gt; NUL
  
  IF ERRORLEVEL 1 (
      goto start
  ) ELSE (
      goto loop
  )
  
  :start
      NET START "Tomcat7"
  </code></pre>
  
  <p>Java code:</p>
  
  <pre><code>   String command = "C:\\Tomcat 7.0\\bin\\restart.bat";
     Process p = Runtime.getRuntime().exec(command);
  </code></pre>
  
  <p>Tomcat is stopped, but not started.
  If I run this batch from command line, it works properly.</p>
  
  <p>thank you for your time</p>