tags:

views:

32

answers:

2

I am executing a.jar file from PHP through Command Line. However, if there is any error/exception, the error is not being displayed. I am using the following PHP script.

<?php
exec('java -jar D:\\ABC\\JavaApplication2\\dist\\JavaApplication2.jar', $result, $returnCode);
var_dump($result);
$count = count($result);
for($i=0; $i<$count;$i++){
    print($result[$i]);
}
?>

The output for the above code is : 'array(0) { }'

A: 

Probably you need to pipe the output of the jar to some file and listen to that file in PHP.

Saky
A: 

don't use exec() if you want to handle I/O, instead use popen() for simple stuff (either read or write) or proc_open() for full fd connectivity, with stdin, stdout, stderr, and possibly other fd's connected (e.g. for openssl).

mvds