[英]I want to compile my java file using php but it shows that javac is not recognised as a command
<?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. 无法将“ javac”识别为内部或外部命令,可操作程序或批处理文件。
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?
我需要将其上传到我的网站上。不知道如何在其上安装jdk或已预先安装?
install JDK and add jdk bin to the PATH
enviorenment variable 安装JDK并将jdk bin添加到
PATH
环境变量
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. 如果使用Windows,请检查SDK中的java bin文件夹并将其添加到
PATH
环境变量中。 If you are on unix system check if the JDK (Sun or OpenJDK is installed) 如果您使用的是Unix系统,请检查是否安装了JDK(已安装Sun或OpenJDK)
You haven't set your java path, first set the class path, 您尚未设置Java路径,请先设置类路径,
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 由@lakshman在上面给出
You need to install jdk. 您需要安装jdk。
If you already installed the jdk, then set the environment variable, so your application can find the jdk path to execute javac command 如果您已经安装了jdk,则设置环境变量,以便您的应用程序可以找到要执行javac命令的jdk路径
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.