title: Execute process from spring webservice and monitor?
body: <p><strong>Question :</strong> I want to execute java jar file from webservice in spring boot project. and want to monitor it.</p>
  <p><strong>Problem :</strong> I am able to execute this process but problem is that process did not processed further.</p>
  <p>I want to know why this process is waiting and why its not processed. how can i monitor its progress.</p>
  <p><strong>its get processed on following conditions:</strong></p>
  <ol>
  <li>Once i stop the spring boot project or tomcat.</li>
  <li>Its get processed if i remove <code>process.waitFor();</code></li>
  </ol>
  <p>I tried the solution from <a href="https://stackoverflow.com/questions/11510409/how-to-monitor-external-process-ran-by-processbuilder">this</a>, that is execute the process from another thread.</p>
  <p><strong>My web service call</strong></p>
  <pre><code>@RequestMapping(value=&quot;/startAnalysis&quot;, method=RequestMethod.POST)
  public String startAnalysis() {
      List&lt;String&gt; cmd = new ArrayList&lt;&gt;();
      cmd.add(&quot;java&quot;);
      cmd.add(&quot;-jar&quot;);
      cmd.add(&quot;test.jar&quot;);
      try {
              //Process p = Runtime.getRuntime().exec(cmd.toArray(new String[0]));
  
              //ProcMon procMon = new ProcMon(cmd);
              //Thread t = new Thread(procMon);
              //t.setName(&quot;procMon&quot;);
              //t.start();
              
              ProcessBuilder processBuilder = new ProcessBuilder(cmd);
              Process process = processBuilder.start();
              process.waitFor();
              
      } catch (Exception e) {
          e.printStackTrace();
      }
      return &quot;success&quot;;
  }
  </code></pre>