title: Run Java class file from PHP script on a website
body: <p>I have a website and want to be able to allow the user to run a Java file on the server from the website. </p>
  
  <p>I want the user to click a button which will run the Java file on the server AND anything printed to standard-out by the Java program will be printed out on the website for the user to see.</p>
  
  <p>How can this be done (call Java program from PHP and feed the standard out from the Java file back to the PHP website in real time)?</p>
  
  <p><b>Update:</b></p>
  
  <p>Thanks for the answers on how to run the Java program from PHP. However I also want to be able, as the Java program is printing to stdout where it will be printing out a lot of text as it is executing, to be able to print this out on the webpage so that the user can see what stage the Java program is in its execution. </p>
  
  <p>How can this be done and does it require any additional AJAX or JavaScript or anything like that?</p>