I'm trying to execute a java program to sign a pdf file with php exec function but doesn't work:
exec('java -jar PROGRAM.jar -n -t ORIGIN.pdf -o DESTINY.pdf -s CERTIFICATE -p PASSWORD', $output, $return);
When I execute it, the $output is an empty array and $return is an int(1), but if I run:
java -jar PROGRAM.jar -n -t ORIGIN.pdf -o DESTINY.pdf -s CERTIFICATE -p PASSWORD
In command line it works. Can anyone help me?
Thank you.
解决方案
Finally I could resolve the problem.
The solution is:
exec('java -Djava.awt.headless=true -jar PROGRAM.jar -n -t ORIGIN.pdf -o DESTINY.pdf -s CERTIFICATE -p PASSWORD', $output, $return);
Adding the -Djava.awt.headless=true option you're telling java that it's an indirect call so it hasn't control over keyboard, mouse, etc.