title: Execute phantomjs script in java program
body: <p>I have a problem: I have to execute a phantomjs script in java program but I can't.
  this is the code of the script:</p>
  
  <pre><code>var page = require('webpage').create();
  page.open('http://stackoverflow.com',function(status){
  if(status !== 'success'){
      console.log('Open failed');
  }else{
     console.log(page.evaluate(function(){
          return document.documentElement.outerHTML;
     }));
  } 
  phantom.exit();
  });
  </code></pre>
  
  <p>In practice, I want to execute the javascript of a web page and after take the html resultant. 
  I tried with the code at this link <a href="https://stackoverflow.com/questions/16889950/running-phantomjs-from-javascript-jsp-or-java">Running Phantomjs from javascript, JSP or Java</a> but my program is blocked at this line</p>
  
  <pre><code>int exitStatus = process.waitFor();
  </code></pre>
  
  <p>what can I do to resolve this??</p>
  
  <p>Thanks</p>