Error related to Android SDK ANT build file while building for Android in Ionic framework

while building for android, I have an error related to ant build file in android sdk\tools. The error is:

C:\Android\adt-bundle-windows-x86_64-20140702\sdk\tools\ant\build.xml:734: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\Program Files\Java\jre1.8.0_25"

I am using Java SDK 1.6 in JAVA_HOME. I am not sure from where it is picking this JAVA_HOME path. The following environment variables are set correctly:

  1. JAVA_HOME to 1.6.
  2. ANDROID_HOME
  3. ANT_HOME

All paths are referenced. But, still getting this error.

Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\Program Files\Java\jre1.8.0_25"

The path C:\Program Files\Java\jre1.8.0_25 seems to refer to a JRE, not a JDK and this is why the compiler is missing. The JDK home would be something similar to C:\Program Files\Java\jdk1.8.0_25.

I had the same issue, and none of the other answers worked.

Originally when I would run the following build command

echo %JAVA_HOME%

It would output the path to the JDK with the /bin folder appended to the end, so I tried removing this and then resetting the environment variable and it worked.

I'm not sure why Ionic does this but the steps I used to fix this were the following:

First check the path %JAVA_HOME% is set to:

echo %JAVA_HOME%

Mine came up with the proper response but Ionic was still having trouble compiling the whole ordeal.

Then I:

  1. SET JAVA_HOME= [put the path to JDK such as C:\java\jdk8]

  2. Went back into environment variables and added the path again for the specific version of JDK I was using.

Here is a link that provides more details.