Hi I'm new to programming in PHP. I use a WAMP server -> Apache version 2.4.4 and PHP version 5.4.16
I want to execute java program from php script, here's my java program
file : test.java
import java.io.*;
public class test {
public static void main(String args[]) {
System.out.println("Hello World");
}
}
I used
exec("javac test.java");
exec(java test);
and it's no use. So then I tried to put the command code in "runfile.bat"
javac test.java > error.txt
java test > output.txt
when I execute runfile.bat by left clicking twice, it run perfectly and there's text "Hello World" in output.txt
then I try from PHP:
exec('start /B /C runfile.bat');
... and output.txt has nothing in it.
execor Task Scheduler you should add the working directory.$curdir = getcwd(); chdir('./Programs'); echo getcwd(); $result=shell_exec('cmd.exe /b /c runfile.bat'); echo $result; chdir($curdir);