<?php echo shell_exec("javac test.java 2>&1");
echo exec("java test 2>&1");
?>
The above code shows the following error:
'javac' is not recognized as an internal or external command, operable program or batch file.
Help me resolve this please. I need to upload this on my website..don't know how to install jdk on that or is it pre installed?
install JDK and add jdk bin to the PATH
enviorenment variable
or
run this command it will solve your problem
<?php
echo shell_exec(set path=C:\Program Files\Java\jdk1.7.0_09\bin);//your path to jdk bin
echo shell_exec("javac test.java 2>&1");
echo exec("java test 2>&1");
?>
If you are using Windows, check and add the java bin folder from the SDK to the PATH
environment variable. If you are on unix system check if the JDK (Sun or OpenJDK is installed)
You haven't set your java path, first set the class path,
or use
change in your environment variables and write like this
name=path
value=C:\Program Files\Java\jdk1.7.0_09\bin;
or try this
set path=C:\Program Files\Java\jdk1.7.0_09\bin;//your path to jdk bin
echo shell_exec("javac test.java 2>&1");
echo exec("java test 2>&1");
Which is given above by @lakshman
You need to install jdk.
If you already installed the jdk, then set the environment variable, so your application can find the jdk path to execute javac command
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.