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
I am at my wit's end. Can anyone help me figure out what's wrong?
CodePudding user response:
I can see a couple of problems here. The following instructions should help you resolve the issue:
- The installation path has
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. - While installing, the installer gives you an opportunity to change the installation location. The default suggested location has space that may be problematic and therefore I recommend you change it to something like
C:\jdk
. - Append the path of JDK
bin
folder to thePATH
environment variable e.g. if the path ofbin
folder isC:\jdk\jdk1.8.0_301\bin
, append this to thePATH
environment variable and also move it to the top position. - Create a new environment variable,
JAVA_HOME
and putC:\jdk\jdk1.8.0_301
(i.e. the path, one level above thebin
folder) as the value into it. - Finally, start a new cmd window and test the command,
java -version
.