Reputation: 101
I'm trying to run a .jar application from PHP using exec:
exec('java -jar parser.jar $inputstring 2>&1', $output);
I can get it to run on cmd, and java -version returns so I have java installed. It seems like this is a path issue, but I am at my wits end.
I've tried specifying the full path, adding C:\Program Files (x86)\Java\jdk1.8.0_91\bin; to System Variables, using shell_exec, no avail. I get the same error.
Any help would be greatly appreciated.
Upvotes: 9
Views: 879
Reputation: 339
Use this....
exec('java -jar parser.jar '.$inputstring.'2>&1', $output);
or
shell_exec("java -jar parser.jar $inputstring 2>&1 $output");
or
string exec ( 'java -jar parser.jar' [, array &$output [, int &$return_var ]] )
Upvotes: 1