I have tried every which way to declare JAVA_HOME in my system variables, but I keep getting the following error when running 'ionic Cordova build --release android'
Failed to run "javac -version", make sure that you have a JDK version 8 installed.
You can get it from the following location:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Your JAVA_HOME is invalid: C:\Program Files (x86)\Java\jdk1.8.0_301
I've tried appending it with "bin", I've tried wrapping C: Program Files (x86) in double quotes, I've tried uninstalling and reinstalling java, and I always get the same error. When I run echo %JAVA_HOME% it gives me:
C:\Program Files (x86)\Java\jdk1.8.0_301
How can I figure out what's wrong?
I can see a couple of problems here. The following instructions should help you resolve the issue:
x86
which suggests that you have installed a 32-bit version of JDK. If your OS is 64 bit (which is mostly the case), download and install the 64 bit JDK.C:\jdk
.bin
folder to the PATH
environment variable e.g. if the path of bin
folder is C:\jdk\jdk1.8.0_301\bin
, append this to the PATH
environment variable and also move it to the top position.JAVA_HOME
and put C:\jdk\jdk1.8.0_301
(i.e. the path, one level above the bin
folder) as the value into it.java -version
.