JAVA_HOME 设置为无效目录:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45182717/
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
JAVA_HOME is set to an invalid directory:
提问by Nagarajan M
I have set JAVA_HOME
in my system C:\Program Files\Java\jdk1.8.0_
131\bin;
and I am trying to run cordova command( cordova build ) on command prompt, but I'm getting the error bellow. I have tried all the ways, but not able to resolve this issue:
我已经JAVA_HOME
在我的系统中进行了设置,我C:\Program Files\Java\jdk1.8.0_
131\bin;
正在尝试在命令提示符下运行 cordova 命令(cordova build),但是我收到了下面的错误。我已经尝试了所有方法,但无法解决此问题:
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_ 131\bin;
错误:JAVA_HOME 设置为无效目录:C:\Program Files\Java\jdk1.8.0_131\bin;
Please, set the JAVA_HOME
variable in your environment to match the
location of your Java installation.
请JAVA_HOME
在您的环境中设置变量以匹配您的 Java 安装位置。
回答by Sagar Gangwal
You should set it with C:\Program Files\Java\jdk1.8.0_12
.
你应该用C:\Program Files\Java\jdk1.8.0_12
.
\bin
is not required.
\bin
不需要。
回答by Kiran Choudhary
JAVA_HOME
should point to the home jdk directory, and not to jdk/bin
directory.
JAVA_HOME
应该指向主 jdk 目录,而不是jdk/bin
目录。
You need to set the JAVA_HOME
like this:
你需要这样设置JAVA_HOME
:
JAVA_HOME="C:\Program Files\Java\jdk1.8.0_131"
回答by Dexter
Remove the \bin
, and also remove the ;
at the end. After restart the cmd and run.
删除\bin
,并删除;
末尾的 。重启cmd后运行。
回答by Abdulrahman Hashem
Try the following:
请尝试以下操作:
- Remove
\bin
fromJAVA_HOME
path. - Open new command line window.
- Run your command as an administrator.
\bin
从JAVA_HOME
路径中删除。- 打开新的命令行窗口。
- 以管理员身份运行您的命令。
回答by Mehrdad Salimi
On Window 10, the problem was with the semicolon ;
.
在 Window 10 上,问题出在分号上;
。
Go to edit the system environment variables
and delete the semicolon at the end of JAVA_HOME
value C:\Program Files\Java\jdk1.8.0_144
转到edit the system environment variables
并删除JAVA_HOME
值末尾的分号C:\Program Files\Java\jdk1.8.0_144
In other words, convert this C:\Program Files\Java\jdk1.8.0_12;
to C:\Program Files\Java\jdk1.8.0_12
换句话说,将其转换C:\Program Files\Java\jdk1.8.0_12;
为C:\Program Files\Java\jdk1.8.0_12
You might have to delete your entry in the Windows Dialog and create a new one. If you ever had multiple entries and get the bigger Form view, Windows automatically inserts a ;
at the end of each entry, even if you only have one entry left.
您可能必须删除 Windows 对话框中的条目并创建一个新条目。如果您曾经有多个条目并获得更大的Form view,Windows 会自动;
在每个条目的末尾插入一个,即使您只剩下一个条目。
回答by Shailja Pandey
set JAVA_HOMEas C:\Program Files\Java\jdk1.8.0_172
将JAVA_HOME 设置为C:\Program Files\Java\jdk1.8.0_172
do not use semicolon ";" with above JAVA_HOME value
不要使用分号“;” 具有以上 JAVA_HOME 值
To verify that it is correctly set, Go to command promptcheck for C:.......>sdkmanager --list
要验证它是否设置正确,请转到命令提示符检查 C:.......> sdkmanager --list
a complete list will appear that will let you now that it is successfully saved.
将出现一个完整的列表,现在它已成功保存。
else it will show error that JAVA_HOME path is not correctly set.
否则它会显示 JAVA_HOME 路径设置不正确的错误。
回答by Pawan Maheshwari
JAVA_HOME should be C:\Program Files\Java\jdk1.8.0_172
don't include semi-colon(;) or bin in path. Any jdk version above 7 will work. Also, you need to re-start the cmd
JAVA_HOME 不应C:\Program Files\Java\jdk1.8.0_172
在路径中包含分号(;) 或 bin。任何 7 以上的 jdk 版本都可以使用。另外,您需要重新启动cmd
回答by Mostafa Yehya
i think you need to remove the ';' from the end of the java path.
我认为你需要删除';' 从java路径的末尾。
回答by Raafat Alhmidi
After setting the JAVA_HOME variable, run android studio as administrator
设置JAVA_HOME变量后,以管理员身份运行android studio
回答by Mak
You need to set with only C:\Program Files\Java\jdk1.8.0_12.
你只需要设置 C:\Program Files\Java\jdk1.8.0_12。
And check with using new cmd. It will be updated
并使用新的 cmd 检查。会更新的