title: How to use php 'exec' to run .jar with input parameters
body: <p>I have a php file which runs a '.jar' file. Code is given bellow<br></p>
  
  <pre><code>exec("java -Xmx1g -jar \"C:\Users\Roxy\Documents\NetBeansProjects\Entity Extraction\dist\Entity Extraction.jar",$output);  
  </code></pre>
  
  <p>This works fine without any error<br>
  But now I need to pass an array (lets say <strong>$testArray</strong>) with this command to 'Entity Extraction.jar' file and access it in my main method in java code.</p>
  
  <p>Can anyone please tell me how to do this?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>In my php file, I have</p>
  
  <pre><code>$testArr[0] = 'test1';
  $testArr[1] = 'test2'; 
  
  $str = "java -Xmx1g -jar \"C:\Users\Roxy\Documents\NetBeansProjects\Entity Extraction\dist\Entity Extraction.jar ";
  
  foreach($testArr as $param){
   $str.=$param.' ';
  }
  
  exec($str,$output);
  print_r($output);
  </code></pre>
  
  <p>In my java Main Class, I have</p>
  
  <pre><code>public static void main(String[] args) {
       int length = args.length;
       for (int i = 0; i &lt; length; i++) {
            System.out.println(args[i]);
       }
  }
  </code></pre>