java 如何修复 JAVA_HOME 对cordova 无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38525851/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 03:29:40  来源:igfitidea点击:

How to fix JAVA_HOME is invalid for cordova

javacordovasdk

提问by Neil

I have tried reinstalling the JDK a few times
reset the JAVA_HOME
I know that the JAVA_HOME needs to be set to C:\Program Files\Java\jdk1.8.0_102
I know PATH has to be set to C:\Program Files\Java\jdk1.8.0_102\bin
I am confused as to why you have to set user variables and system variables
I set both the JAVA_HOME and the PATH in both User vairables and System variables
I have added "C:\Users\*\AppData\Local\Android\sdk\tools" and "C:\Users\*\AppData\Local\Android\sdk\platform-tools" System "Variables/Path"

我试过几次重新安装 JDK
重置 JAVA_HOME
我知道 JAVA_HOME 需要设置为 C:\Program Files\Java\jdk1.8.0_102
我知道 PATH 必须设置为 C:\Program Files\Java\ jdk1.8.0_102\bin
我很困惑为什么必须设置用户变量和系统变量
我在用户变量和系统变量中都设置了 JAVA_HOME 和 PATH
我添加了“C:\Users\*\AppData\Local \Android\sdk\tools”和“C:\Users\*\AppData\Local\Android\sdk\platform-tools”系统“变量/路径”

Here is an Image of most of the settings, I have tried a few things and cant seem to find the problem any help please

这是大多数设置的图像,我尝试了一些方法,但似乎无法找到问题,请提供任何帮助

Settings and Files

设置和文件

采纳答案by Neil

I eventually solved this by taking it to another device and running as administrator. So if someone ran into a similar problem try running your cmd as administrator or check its permission. After obviously trying most of what was said on this post already and in the comments

我最终通过将其带到另一台设备并以管理员身份运行来解决此问题。因此,如果有人遇到类似问题,请尝试以管理员身份运行您的 cmd 或检查其权限。在显然已经尝试了这篇文章和评论中的大部分内容之后

回答by Ali Khatami

You don't need to include any path in "User Variables for" section.

您不需要在“用户变量”部分中包含任何路径。

Just create JAVA_HOME and ANDROID_HOME variables is "System variables" section.

刚刚创建的 JAVA_HOME 和 ANDROID_HOME 变量是“系统变量”部分。

After that something that you may have forgotten is to include those variables in "path" variable existing in "System variables" section as below: screen capture

之后,您可能忘记的是将这些变量包含在“系统变量”部分中存在的“路径”变量中,如下所示: 屏幕截图

回答by sanju avalon softwares

I had the same issue. I tried all the methods from uninstalling multiple versions, reinstalling latest version, tried inverted commas in paths etc.etc. but the problem was really one invalid path in the existing path variable!!! after removing it, this issue was solved

我遇到过同样的问题。我尝试了卸载多个版本、重新安装最新版本、在路径中使用引号等的所有方法。但问题实际上是现有路径变量中的一个无效路径!!!删除后,这个问题就解决了

回答by L0uis

I had this problem with Visual Studio. I updated the JAVA_HOME variable in tools => options => tools for apache cordova.

我在 Visual Studio 中遇到了这个问题。我更新了工具 => 选项 => apache cordova 工具中的 JAVA_HOME 变量。