title: Run Java programs from PHP in a sandbox
body: <p>I have a little question: we have to run Java programs and parts of the code will be uploaded by the users. 
  So I want to know what's the best way to run them? I know 2 possible ways, </p>
  
  <ol>
  <li><code>exec("javac Usercode.class")</code> and then run the whole thing with <code>exec("java Main")</code>, but I tried it with <code>exec()</code> and it don't work. maybe because the http is not root? But I don't know exactly why.</li>
  <li><a href="http://php-java-bridge.sourceforge.net/pjb/" rel="nofollow">http://php-java-bridge.sourceforge.net/pjb/</a> ?</li>
  </ol>
  
  <p>Any suggestions?</p>
  
  <p>And another question is, how can I run these programs in a sandbox. we have a Debian server and so it's no problem to execute the command with a limited time, but is there a possible way to run the whole code in a sandbox?</p>