PHP exec java on IIS 7

2019-08-25 10:12发布

问题:

I am trying to exec a java jar file using php exec();

The command is

"C:\Program Files\Java\jdk1.5.0_15\bin\java.exe" -jar "C:\batik\batik-rasterizer.jar" -m image/png -d "C:/path/to/file/filename.png" -w 800 "C:/path/to/file/filename.svg"

When I run this command on the server using CMD.exe or Power Shell works fine but when I run it with PHP using exec() or system() or shell_exec() it will not execute returning a blank page

回答1:

OK I got it figured out,

First the java jdk shouldn't be installed in the programs folder for some reason iis_iusrs doesn't have the permission to execute any files there.

Secondly the code should look like this

exec("C:\\Java\\jre6\\bin\\java.exe -jar C:\\batik\\batik-rasterizer.jar -m image/png -d "C:\\path\\to\\file\\filename.png" -w 800 "C:\\path\\to\\file\\filename.svg");