Running java through PHP from source file and save output
<p>I am developing an online coding competition application. In this I want the code submitted to be compiled and executed. If the submitted code is in Java I am able to compile it using <code>exec</code> (javac filename).</p>

<p>But how should I run that code such so it will take input from a file and redirect the output to another file? Any other way to check that code for various test cases will also be useful.</p>

<pre><code>exec('java ./$path &gt; ./$dest')
</code></pre>

<p>This is what I am using to execute but it is not working.</p>