JAVA_HOME is invalid (cordova) error

10,449

Solution 1

The reason is that JAVA_HOME path have space for the value Program Files,you need add " to wrap it

JAVA_HOME="C:\Program Files"\Java\jdk1.8.0_172

Solution 2

I hope this info can be usefull... this is a resume from many threads I read on Internet...

I have Windows 10 x64

Previously I installed JRE, JDK and Android Studio.

Here is where you can find Android SDK path on your system after install Android Studio

After to set on system enviroments vars JAVA_HOME and ANDROID_HOME (with android sdk path), then I added to path var the following:

  • %JAVA_HOME%\bin
  • %ANDROID_HOME%\tools

Now You could run cordova run android and cordova build android commands from cmd.exe console.

From Git Bash MINGW64 I always have your error.

My System Enviroments vars

My system path var configuration

Share:
10,449

Related videos on Youtube

Ikeh Henry
Author by

Ikeh Henry

Updated on June 04, 2022

Comments

  • Ikeh Henry
    Ikeh Henry about 2 years

    I have been experiencing this error for the past 7 days. I have researched various helps online but all to no avail:

    I am using windows 10, 4gb RAM, 32 bit.

    (node:2240) UnhandledPromiseRejectionWarning: CordovaError: Failed to run "javac -version", make sure that you have a JDK installed. You can get it from: http://www.oracle.com/technetwork/java/javase/downloads. Your JAVA_HOME is invalid: C:\Program Files\Java\jdk1.8.0_172

    What should I do?

    • keval nayak
      keval nayak almost 6 years
      to check jdk install or not type "javac" in cmd. if jdk proper install then return list of command else give error.
  • Ikeh Henry
    Ikeh Henry almost 6 years
    I followed step 5, but I run java -version in my CMD it brought this errow C:\WINDOWS\system32>java -version Picked up _JAVA_OPTIONS: -Xmx1024 Error occurred during initialization of VM Too small initial heap
  • lucumt
    lucumt almost 6 years
    @IkehHenry how do you test it,from cmd or IDE?
  • Ikeh Henry
    Ikeh Henry almost 6 years
    I did not understand your suggestion
  • jguyet
    jguyet almost 6 years
    OK javac was not found so you simply added the variable Manually. or by downloading Java JDK
  • Ikeh Henry
    Ikeh Henry almost 6 years
    I am also getting this issue when I tried to reinstall new jdk Error: Could not create the Java Virtual Machine. Error: A fatal exception occured. Program will exit.