title: Execute java class in PHP
body: <p>I want to call a java program and fetch it's output in stdout. I followed the suggestions in  <a href="https://stackoverflow.com/questions/2128619/run-java-class-file-from-php-script-on-a-website">stackoverflow</a>. But it doesn't work.</p>
  
  <p>I have add the class file to my CLASSPATH. And I can execute the command in cmd correctly as follows:</p>
  
  <p><img src="https://i.stack.imgur.com/D4vQR.png" alt="enter image description here"></p>
  
  <p>In my PHP file I call this program by </p>
  
  <pre><code>exec("java Hello", $output);
  print_r($output);
  </code></pre>
  
  <p>It yields nothing but:</p>
  
  <pre><code>Array()
  </code></pre>
  
  <p>What is the problem? How can I fix this?</p>
  
  <p>ps: Hello is a demo program, actually the program I want to call is much more complicated which might take 2 or more seconds in my machine(i5 4G). </p>