Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix JAVA_HOME is invalid for cordova

Tags:

java

sdk

cordova

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"

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

like image 558
Neil Avatar asked Jul 22 '16 11:07

Neil


People also ask

How do I fix Java Home error?

Download Liberica JDK and on installation it will automatically set JAVA_HOME environment variable. Now you just go to Android Studio -> Project Structure -> SDK -> Point all jdk path to liberica jdk installation directory and apply. You are done. Just restart android studio and gradle command will work.

Why JAVA_HOME is not working?

Verify JAVA_HOME Enter the command echo %JAVA_HOME% . This should output the path to your Java installation folder. If it doesn't, your JAVA_HOME variable was not set correctly. Please make sure you're using the correct Java installation folder, or repeat the steps above.

How do you fix please set the JAVA_HOME variable in your environment to match the location of your Java installation?

Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.

What happens if JAVA_HOME is not set?

If any program that requires a Java runtime fails to find the JAVA_HOME environment variable upon startup, or if the JAVA_HOME environment variable is misconfigured, it will result in some of the following error messages to be displayed: A Java installation exists but JAVA_HOME has been set incorrectly.


3 Answers

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.

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

like image 159
Ali Khatami Avatar answered Sep 30 '22 17:09

Ali Khatami


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

Update

One issue I found on another device recently (2 years after the original issue) is I was running a shell version of CMD not the default CMD which was not gaining access to the Java_Home property. Be sure to check that as a possible cause as well.

like image 36
Neil Avatar answered Sep 30 '22 18:09

Neil


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

like image 29
sanju avalon softwares Avatar answered Sep 30 '22 19:09

sanju avalon softwares