Search code examples
javawindowscordovaphonegap-plugins

Cordova can't find my Java installation, but JAVA_HOME looks valid. What's going on?


Windows 7 64-bit, with 64-bit JDK. Cordova plugman 1.4.2-dev. Using cygwin bash as a shell, but I don't see why that would affect anything.

$ echo $JAVA_HOME
"c:\Program Files\Java\jdk1.8.0_25"

$ echo $ANDROID_HOME
C:\Users\admin\AppData\Local\Android\Sdk

$ ls "c:\Program Files\Java\jdk1.8.0_25"
bin        include         lib          release
COPYRIGHT  javafx-src.zip  LICENSE      THIRDPARTYLICENSEREADME.txt
db         jre             README.html  THIRDPARTYLICENSEREADME-JAVAFX.txt

$ ./main.js install --platform android --project ../myproject/ --plugin phonegap-facebook-plugin-gtg --variable APP_ID="1155264567919069" --variable APP_NAME="Voice Test"
Fetching plugin "phonegap-facebook-plugin-gtg" via npm
Installing "phonegap-facebook-plugin" for android
Failed to install 'phonegap-facebook-plugin':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_25"

I've also tried using JAVA_HOME without the quotes. What's going on?


Solution

  • @cubrr gave the correct answer in the comments. The error message being produced by Cordova is extremely misleading: the problem isn't that JAVA_HOME was incorrect, but that javac wasn't on my path. This was made all the more confusing by the fact that java was on my path, so when I checked it gave correct results. This is because the Oracle installer adds a directory to your path (c:\ProgramData\Oracle\Java\javapath) that contains links to java.exe and related programs but not the relevant JDK programs.