简体   繁体   English

我想使用php编译我的java文件,但它表明javac无法识别为命令

[英]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.

相关问题 在Windows命令提示符下无法使用javac编译.java文件 - Unable to compile .java file using javac at Windows command prompt 在命令行上运行 Java 类时出现“Javac 未被识别为内部或外部命令、可运行的程序或补丁文件” - Getting “Javac is not recognised as internal or external command, operable program or patch file” while running Java class on command line 无法在ubuntu(APARAPI)上使用JDK下的javac命令编译java文件 - Cannot compile java file using javac command under JDK on ubuntu (APARAPI) 使用javac和命令行编译java文件 - Compiling a java file using javac and the command line 无法在cmd上使用javac编译.java文件 - Can't compile .java file using javac on cmd Java File runs with java FileName.java command but doesn't compile with javac Filename.java - Java File runs with java FileName.java command but doesn't compile with javac Filename.java 如何使用javac编译java包结构 - How to compile java package structures using javac 为什么 javac *.java 命令不能从 eclipse 编译文件? - Why won't javac *.java command work to compile the file from eclipse? 当我试图通过“javac”命令编译一个file.java时,它给了我“找不到文件”错误,虽然我已经完成了JDK的路径和变量 - When I am trying to compile a file.java by “javac” command, it gives me “file not found” error, though I have done the path and variable of JDK 如何查看IntelliJ IDEA用于编译代码的javac命令? - How can I see the javac command IntelliJ IDEA uses to compile my code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM