I have a php file which runs a '.jar' file. Code is given bellow
exec("java -Xmx1g -jar \"C:\Users\Roxy\Documents\NetBeansProjects\Entity Extraction\dist\Entity Extraction.jar",$output);
This works fine without any error
But now I need to pass an array (lets say $testArray) with this command to 'Entity Extraction.jar' file and access it in my main method in java code.
Can anyone please tell me how to do this?
Update:
In my php file, I have
$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);
In my java Main Class, I have
public static void main(String[] args) {
int length = args.length;
for (int i = 0; i < length; i++) {
System.out.println(args[i]);
}
}