简体   繁体   English

无法在系统变量中设置Java路径(Windows 10)

[英]Unable to set Java Path in system variables (Windows 10)

I've tried adding JAVA_HOME with the directory - C:\\Program Files\\Java\\jdk1.8.0_121 to my system variables, and then adding %JAVA_HOME%/bin to Path variable and this didn't work and I receive 我尝试将具有目录-C:\\ Program Files \\ Java \\ jdk1.8.0_121的JAVA_HOME添加到我的系统变量中,然后将%JAVA_HOME%/ bin添加到Path变量中,但这没有用,我收到了

'java' is not recognized as an internal or external command, operable program or batch file. 无法将“ java”识别为内部或外部命令,可操作程序或批处理文件。

So I've tried adding C:\\Program Files\\Java\\jdk1.8.0_121; 所以我尝试添加C:\\ Program Files \\ Java \\ jdk1.8.0_121; directly to the path variable but I still get the above error. 直接到路径变量,但我仍然收到上述错误。 Does anyone have any suggestions please? 请问有人有什么建议吗?

Thanks 谢谢

PS - The image shows me in the command prompt at C:\\Program Files\\Java\\jdk1.8.0_121 trying 'java -version' - I just moved up one dir to test the variable, entering 'java -version' in the bin directory returns the correct info, as you would expect. PS-该图像在C:\\ Program Files \\ Java \\ jdk1.8.0_121的命令提示符下显示了我尝试'java -version'的情况-我只是将一个dir向上移动以测试该变量,然后在bin中输入了'java -version'目录返回正确的信息,正如您所期望的那样。

链接到图片

您是否尝试关闭该命令提示符并重新打开?

In the command line, run the following: 在命令行中,运行以下命令:

set PATH=%PATH%:C:\\Program Files\\Java\\jdk1.8.0_121\\bin

Without exiting the shell, run your java commands 在不退出外壳的情况下,运行Java命令

Eg 例如

java -version

This will surely work. 这肯定会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM