Cordova : Requirements check failed for JDK 1.8 or greater
I am using Cordova 6.4.0 in Windows 7 OS, but I get this error once I tried to build the android version :
The Java Home variable is setted correctly to the JDK path, but I don't know why I am getting this issue. Any suggestions please ?
Solution 1:
In Linux (Debian/Ubuntu) this can be solved by selecting a Java 1.8 SDK in
sudo update-alternatives --config javac
Changing JAVA_HOME
env variable directly does not seem to have any effect.
EDIT: responding to the comments: This probably has something to do with the fact that new Debian (and apparently Ubuntu) Java installations through the package manager do not use the JAVA_HOME
enviroment variable to determine the location of the JRE. See this and this post for more info.
Solution 2:
Uninstall all previous JDK including 1.8 Install JDK 1.8
Solution 3:
You don't have to uninstall any higher version of sdk. just install jdk1.8.0_161 or don't if it is already install.
Now just set the JAVA_HOME
USER variable (not system variable) as shown in the below image.
This way you don't have to uninstall higher version and the problem get resolved.
Solution 4:
What worked for was uninstalling jdk 9 and reinstalling jkd 8.x
On Mac in order to uninstall go to the terminal and follow this steps:
cd /Library/Java/JavaVirtualMachines
sudo rm -rf jdk-9.0.1.jdk
Then install the jdk 8.x by downloading the .dmg package from Oracle.
Solution 5:
You may have a version that is greater than 8 but Cordova only supports JDK 1.8. View this link Cordova Documentation
I took a look at the piece of code that actually checks for the version number of your java. Look for the following: module.exports.check_java in platforms/android/cordova/lib/check_reqs.js. on line 220. You will see a regex and comment left by the team that Java 10 will be supported in the future.
The existing regular expression will fail when it is run against the latest versions of java such as Java 10. That is because Java 8 or 9 are saved in the following format: 1.[8-9].** but Java 10 is saved as 10.** and the regular expression looks for a version in the format 1.[8-9].**
// Let's check for at least Java 8, and keep it future proof so we can support Java 10
var match = /javac ((?:1\.)(?:[8-9]\.)(?:\d+))|((?:1\.)(?:[1-9]\d+\.)(?:\d+))/i.exec(output);
My solution:
You don't have to uninstall your current version of the JRE or JDK since the installer installs each version in a specific folder.
1- Install version Java 8 Follow this link
2- Update your environment variables:
- JAVA_HOME if you installed the JDK
- JRE_HOME if you installed the JRE
by pointing them to the location where the JRE 8 and JDK 8 were installed.
// On my machine
C:\Program Files\Java\jdk1.8.0_171 // JAVA_HOME
C:\Program Files\Java\jre1.8.0_171 // JRE_HOME
Open a new terminal session and run the command that was failing. It should work now.
Did not work?
Should it fail for other reasons, possible debugging process:
- Ensure the JAVA_HOME and JRE_HOME variables are System variables.
- Ensure they are added to your User's Path Add variables to Path