JAVA_HOME issue while launching "ionic build android"

Hello there!

I am completely new at ionic, really willing to try something, but I am completely stuck when trying to build the app for android.

As you can see (green underline), it says my JAVA_HOME is invalid, whic h is weird because I double checked, and the path is actually correct.

Any chance someone had this issue before and found a way to solve it?

Many thanks!

P.S. if it can help:
OS: Windows 8.1
Node Version: v0.12.1
Cordova CLI: 4.3.0
Ionic Version: 1.0.0-rc.3
Ionic CLI Version: 1.3.20

What is the value of your JAVA_HOME variable?

Check if you have Java installed! And set JAVA_HOME environmental variable to that jre folder!

Your JAVA_HOME shows to a JRE folder not a JDK.
You have to install JDK.

To build your code for an android platform you have to install android sdk.
I think this could be the reason for the second error.


Here it is:



Yes Java is well installed. Here below is the folder containing the application. Seems to me well setup?


Thanks! Indeed I switch from the JRE folder to the SDK, which was in “Program files”. I used to go only to the “Program files (x86)”, which didn’t have a JDK folder!

Not sure to label this topic as “solved”?

Tired but unable to solve for me.

C:\Users\Ayushman\Documents\Android\myApp>ionic build android

Running command: “C:\Program Files\nodejs\node.exe” C:\Users\Ayushman\Documents\Android\myApp\hooks\after_prepare\010_add_platform_class.js C:\Users\Ayushman\Documents\Android\myApp
add to body class: platform-android
Running command: cmd “/s /c “C:\Users\Ayushman\Documents\Android\myApp\platforms\android\cordova\build.bat””
[Error: Failed to run “java -version”, make sure that you have a JDK installed.
You can get it from:
Your JAVA_HOME is invalid: C:\Program Files\Java\jdk1.8.0_60
ERROR building one of the platforms: Error: cmd: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 2
at ChildProcess.whenDone (C:\Program Files\nodejs\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:139:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)


C:\Users\Ayushman\Documents\Android\myApp>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_60

Hi everyone,
please i need a guard, i am stucked here, i fellowed the installation instructions from getting started but at the point of building my ionic projects , this is the error i get. please any help will be greatly appreciated.



I’m getting the same error as yours where I’ve the JAVA_HOME set to the JDK directory & JDK Bin in the PATH variable but still get the above error.

JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_45;
PATH=C:\Program Files (x86)\Java\jdk1.6.0_45\bin;

Please suggest what could be the problem.


I just had the same problem. I was sure that I installed the JDK and that the JAVA_HOME path was set correctly. However it turned out that I unselected one component during the JDK installation process because I thought that it would install the Java IDE. That resulted in that the java compiler (javac.exe) wasn’t installed. “java.exe” was installed correctly.
The error was gone, after I’ve reinstalled the JDK with all available components.

This is how you can check if your JDK and JAVA_HOME var are installed properly (on Windows):
Open a command promp and enter:

  1. "%JAVA_HOME%"\bin\java -version
  2. "%JAVA_HOME%"\bin\javac -version

The second failed on my machine.

Did you find any solution in the meantime?