0
votes

I have been trying to set up Cordova on my Windows 7 machine. After hours of troubleshooting I believe I have narrowed the problem down to the configuration of ant, but I'm at a loss as to how to fix it.

When executing cordova build from the prompt, under -compile: I get:

BUILD FAILED
C:\path\to\ant\build.xml:601: The following error occurred while executing this line:
C:\path\to\ant\build.xml:720: The following error occurred while executing this line:
C:\path\to\ant\build.xml:734: Unable to find 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(x86)\Java\jre1.8.0_20"

Now the frustrating part is that in my environment variables JAVA_HOME does point to the JDK and not the JRE. When I run set JAVA_HOME I get:

JAVA_HOME=C:\Program Files(x86)\Java\jdk1.8.0_20

When I run echo %JAVA_HOME% I get:

C:\Program Files(x86)\Java\jdk1.8.0_20

Here are all of my relevant environment variables (I think):

ANT_HOME: C:\ant

JAVA_HOME: C:\Program Files(x86)\Java\jdk1.8.0_20

PATH: C:\Program Files (x86)\nodejs\;C:\Program Files (x86)\Git\bin;C:\Development\adt-bundle\sdk\platform-tools;C:\Development\adt-bundle\sdk\tools;C:\Program Files (x86)\Java\jre1.8.0_20\bin;C:\Program Files(x86)\Java\jdk1.8.0_20\bin;C:\Users\Casey Ydenberg\AppData\Roaming\npm;C:\ant\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;

Any suggestions as to what to try?

Thank you, Casey

3
run echo %JAVA_HOME% from the command line. What does it output? - kindasimple
See edits above. echo %JAVA_HOME% outputs: C:\Program Files(x86)\Java\jdk1.8.0_20. - caseyy

3 Answers

0
votes

Its probably a misconfigured environmental variable. Your error message indicates ANT is trying to use the JRE.

Go to System Properties > Environment Variables and make sure there is a system variable for JAVA_HOME set to C:\Program Files(x86)\Java\jdk1.8.0_20. Verify that that folder is where your jdk is installed. Open a new command prompt and type echo %JAVA_HOME% to verify.

0
votes

Based on this answer: Ant Build not able to recognize JAVA_HOME

I tried changing JAVA_HOME to

C:\Progra~2\Java\jdk1.8.0_20 

and the JDK part of the PATH to

C:\Progra~2\Java\jdk1.8.0_20\bin.

It worked (yay), but I have absolutely no idea why.

0
votes

I've written an article about installing Cordova on windows here: http://jewelfarazi.me/installing-cordova-with-android-studio-on-windows/

Your can try this, first add environment variable JAVA_HOME:

C:\Program Files\Java\jdk1.7.0_79

And Then add to environment path:

%JAVA_HOME%\bin

So rather adding the whole path you can do similar for ANT_HOME as well and it should work!