让 javac 在 PATH 环境变量中工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20403902/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Getting javac to work in the PATH environment variable
提问by Mikey
So I've downloaded the latest JDK and installed it. I'm starting to go through a textbook with some tutorials but in no part of the textbook do they tell you how to 'setup' the javac compiler. If I type 'javac' into the command line it simply says it is not a recognised command. I have added the path of the bin folder to the path environment variable but it still says not a recognised command. Please help!!
所以我下载了最新的JDK并安装了它。我开始阅读带有一些教程的教科书,但教科书的任何部分都没有告诉您如何“设置”javac 编译器。如果我在命令行中输入“javac”,它只会说它不是一个可识别的命令。我已将 bin 文件夹的路径添加到路径环境变量中,但它仍然表示不是可识别的命令。请帮忙!!
回答by Vusa
- Check if running
javac
works from within its folder. echo %JAVA_HOME%
and make sure it points to the right folder.echo %PATH%
and make sure it includes the right path.
- 检查运行是否
javac
在其文件夹内工作。 echo %JAVA_HOME%
并确保它指向正确的文件夹。echo %PATH%
并确保它包含正确的路径。
回答by Gambotic
try to use the direct path to the javac like c:/swd/jdk/
尝试使用 javac 的直接路径,如 c:/swd/jdk/
回答by Adam Luniewski
Did you happen to modify PATH variable through command set PATH=%PATH%;C:\path\to\java\
? If so, the PATH variable is not permanently stored yet. Use setx PATH "%PATH%;C:\path\to\java\"
instead, and check if it was added by echo %PATH%
, and check again in new cmd window. I had almost the same problem; I don't know the difference between set and setx, but the former didn't work for me, too :).
您是否碰巧通过命令修改了 PATH 变量set PATH=%PATH%;C:\path\to\java\
?如果是这样,则 PATH 变量尚未永久存储。使用setx PATH "%PATH%;C:\path\to\java\"
替代,并检查它是否被添加echo %PATH%
,并在新的cmd窗口再次检查。我遇到了几乎同样的问题;我不知道 set 和 setx 之间的区别,但前者对我也不起作用:)。
回答by user3054142
Javac is sitting in the bin directory contained in the area where your java compiler and interpreter were installed. So, assuming the path to bin is C:.....\bin, type set path=%path%;C:.....\bin at the command prompt.
Javac 位于安装了 Java 编译器和解释器的区域中的 bin 目录中。因此,假设 bin 的路径是 C:.....\bin,请在命令提示符下键入 set path=%path%;C:.....\bin。