Compile process: You must enter the full path of the Java file exec ("Javac D:\\test.java"),//run and redirect the output, here must be set classpath, and then redirect the path also if the full path $res = EXEC ("Set Classpath=d:\\&java Test < D:\\in.txt > d:\\out.txt ", $out, $status);//print out the status value, if 0 indicates success, 1 indicates failure Var_dump ($ status);//If not redirected, RES will use an array to hold the output of//system.out.println () Print_r ($res);
Test.java source files are as follows:
Import java.util.*;p ublic class test{public static void Main (string[] args) {System.out.println ("java php"); Scanner in = new Scanner (system.in), for (int i = 0; i <; i++) {int n = in.nextint (); SYSTEM.OUT.PRINTLN (n);}}
The above describes the PHP compiler to execute Java source files and redirect the output, including Java, source file aspects of the content, I hope that the PHP tutorial interested in a friend helpful.