橫幅廣告

2015年4月8日 星期三

Let your PHP calls JAR of JAVA (Windows)

Set the identity of executor for Apache

Before run your php program.

You have to set the identity of executor for Apache.


  1. Go to "Service"

  2. Change the executor (use your log-in account)


Write a toy program

// Set Enviromental Variable
$JAVA_HOME = "C:\\\"Program Files\"\\Java\\\"jre1.8.0_20";
$PATH = "C:\\\"Program Files\"\\Java\\\"jre1.8.0_20\"\\bin";
putenv("JAVA_HOME=$JAVA_HOME");
putenv("PATH=$PATH");

//run your jar program
echo shell_exec("java.exe -version 2>x.txt");


Finally, execute PHP program

沒有留言:

張貼留言