[cordova] 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 :

Issue description

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 ?

This question is related to cordova cordova-cli

The answer is


Uninstalling older versions of JDK would have worked. But it may be a workaround i guess. I faced the same issue and noticed that both new version of JDK and older version JDK path has been mentioned in 'path' environmental variable.

Removing the older version JDK path from 'path' environmental variable did the trick for me. Hope it helps someone too.


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.


This error message make user confuse, the success screen as below.cordova build success

The error message make user try to fix the build fail with JAVA_HOME config. But the real problem is not just in the JAVA_HOME.

I fix this problem with correct config in JAVA_HOME and Path in "system variable". enter image description here

Hope can help to fix the problem, but not re-install JDK.


if you have many version of JDK you can run

export JAVA_HOME="/usr/local/env/java/jdk1.8.0_131.jdk/Contents/Home/"

before cordova build, to use a specific version of jdk :)


It's an old question, but since i just had the same problem, but the error had another source, here a short answer.

Problem accured on Windows (only) and with the Webstorm IDE 2019.2

In the version 2019.2 Webstorm had an issue, because it internally used open jdk for the %JAVA_HOME% variable instead of the (from the os) targeted java jdk.

In my case (yeah it's old, it's an old cordova project ... )

executing java -version in Windows cmd.exe:

$ java -version
java version "1.8.0_221"

but executing java -version in Webstorms terminal:

$ java -version
openjdk version "11.0.3" 2019-04-16
// more output

A fix came with the patch released later (today), version 2019.2.1. Now Webstorm uses the os %JAVA_HOME% variable as it should and the java -version output is identical in both cases.

Hope it helps someone!


if you have multiple Java versions installed and need to keep those, you need to check following things:

  • JAVA_HOME pointing to your jdk1.8
  • in your PATH variable you need to check that jdk1.8\bin path is before the other jdk\bin paths

I just renamed older JDK folder with _, just in case if I need it further, and it worked.

C:\Program Files (x86)\Java\_jdk1.7.0_40 
C:\Program Files (x86)\Java\_jre7

I was running into the same problem yesterday with my new laptop (all new installation), with the only execption that for me Cordova said:

Requirements check failed for JDK 8 ('1.8.*')! Detected version: null

That Detected version: null was the actual problem for me!

When looking into the check_reqs.js (as mentioned in a post above) you will notice that this is where the magic happens: It contains a function "check_java" that, at some point, uses "execa" to retrieve the installed version of Java:

return execa('javac', ['-version'], { all: true })
    .then(({ all: output }) => {
        // Java <= 8 writes version info to stderr, Java >= 9 to stdout
        const match = /javac\s+([\d.]+)/i.exec(output);
        return match && match[1];
    }

The problem for me was that, for whatever reason, I had an outdated version of "execa" which does not contain the "all" property that was used for the output. Hence, the retrieved version of Java was always undefined. By adding "execa": "^4.0.2" to my dependencies in the package.json and running "npm i" again I was able to fix this problem.

Just wanted to share this insight.


The answer posted by MadNeox is correct.I was facing a similar issue I had jdk 9 installed as well as the 1.8 version

I first tried by keeping jdk 9 and removing 1.8 it would display an error Requirements check failed

Then I tried by uninstalling jdk9 and reinstalling 1. this time it was showing failed to run javac-version

After playing around with the Environment variables for some time I finally got the solution

At this point my system only has jdk 1.8 Cordova version:7.1.0

-Open Environment Variables tab -Under user variables create a new variable PATH -give it the following value C:\Program Files\Java\jdk1.8.0_151\bin (might change depending on where you have installed your jdk)

This should solve your problem Hope it helps

Although the answer was already given it did take me some time to figure out where I was going wrong so decided to post this hoping it would save someone else's time


The error occurs when the default path to java is set to a version other than Java 8 or JDK 1.8.*

For my case, I have installed Java 11 after installing Java 8

You can test by running:

java -version

For my case it returned:

java version "11.0.8" 2020-07-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.8+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode)

To fix this, we need to ensure the java path is pointed to Java 8 binaries instead

Assuming you already have Java 8 or JDK 1.8.* installed:

  1. Make sure JAVA_HOME and JRE_HOME is set (make sure it points to Java 1.8.*)

Env variable

  1. Inside PATH, Make sure %JAVA_HOME%\bin or C:\Program Files\Java\jdk1.8.0_251\bin is added

enter image description here

  1. Source of the problem: My JDK 11 installation added two PATH entries right at the top, taking precedence or overriding the %JAVA_HOME%\bin PATH that points to JDK 1.8.*

Do not add these if you don't have them, find other PATH entries that may override %JAVA_HOME%\bin

enter image description here

  1. Click "Move Down" for the overriding entries until they are below %JAVA_HOME%\bin

%JAVA_HOME%\bin PATH that points to Java 8 will now be prioritized over the other PATH entries that points to JDK 11

enter image description here

  1. Save, and open a new terminal and run
java -version

For my case it then returned:

java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)

Fixed!


MacOS answer with multiple Java versions installed and no need to uninstall

Show me what versions of Java I have installed :

$ ls -l /Library/Java/JavaVirtualMachines/

To set it to my jdk1.8 version :

$ ln -s /Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home/bin/javac /usr/local/bin/javac

To set it to my jdk11 version :

$ ln -s /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home/bin/javac /usr/local/bin/javac

-------------------------------------------------------------------------

Note that, despite what the message says, it appears that it means that it wants version 1.8, and throws this message if you have a later version.

What follows is my earlier attempts which lead me to the above answer, which then worked ... You might need to do something different depending on what's installed, so maybe these notes might help :


Set it to my jdk1.8 version

$ export PATH=/Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home/bin/javac:$PATH

Set it to my jdk11 version

$ export PATH=/Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home/bin/javac:$PATH

... but actually that doesn't work because /usr/bin/javac is still what runs first :

$ which javac
/usr/bin/javac

... to see what runs first on the path :

$ cat /etc/paths
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

That means I can override the /usr/bin/javac ... see the commands at the top of the answer ...
The command to set it to jdk1.8 using ln, at the top of this answer, is what worked for me.


in my case JAVA_HOME was pointing to C:\Program Files (x86)\Java\jdk1.7.0_55

when i wrote where java in cmd it outputted C:\Program Files (x86)\Java\jdk1.7.0_55 along side with java.exe path,i've changed the JAVA_HOME variable from environment variables to C:\Program Files\Java\jdk1.8.0_20 & it worked, so it seems i had 2 jdk instances & cordova needs the v1.8.* one.


As per official Cordova documentation it supports only JDK 1.8 not greater till the date (April 2018). Or there might be problem with version detection script within cordova.

Cordova: Installing the requirements


Just make sure that same JDK versions(i.e. 1.8 in this case) are accessible from PATH environment variable and JAVA_HOME. Example: If JAVA_HOME=C:\Program Files\Java\jdk1.8.0_152 then PATH variable should also contain above path and importantly before any (if there are any) other path of if JDK/JRE already mentioned in the PATH variable. You may choose to uninstall other versions if no other application is using different version of java.


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.

enter image description here

This way you don't have to uninstall higher version and the problem get resolved.


  1. Go to Control panel Home
  2. Advanced System Settings
  3. Environment Variables
  4. Choose JAVA_HOME
  5. edit
  6. variable value for the 1.8 one

I'm using windows and having two jdk 1.8 and 14 version something ...

Faced same issue and after some debugging find the solution.

  1. set JAVA_HOME correctly.
  2. Change the user variable PATH value with new jdk (1.8) version.
  3. Change the user variable PATH value with new jdk (1.8) version.

And it solved


Sometimes changing the path and java-home does not work. You need to add

C:\Users\[your user]\AppData\Local\Android\Sdk\platform-tools
C:\Users\[your user]\AppData\Local\Android\Sdk\tools

to the environmental variable path as well.


Guys to get the mix right on Windows, you need to do the following

  1. Download and install any version of JDK 1.8 or higher.
  2. Open environment variables, create an environment variable called JAVA_HOME and set value to JDK install path. C:\Program Files\Java\jdk1.8.0_162 make sure you do not add the \bin in the value.

enter image description here

  1. In your system path variable, put a semi-colon ; and add this value to system path e.g C:\Program Files\Java\jdk1.8.0_162\bin; Here the \bin is added.

Note: The environment variables are tricky.They are supposed to be closed by a ; before opening another. That is why we put one before adding the value and one after the value to close it.

enter image description here

  1. Now close terminal and reopen then run previous commands.

I faced the same issue with jdk1.8.0_201.It got resolved when I made JAVA_HOME=C:\Program Files\Java\jdk1.8.0_201 and added "C:\Program Files\Java\jdk1.8.0_201\bin" in path variable


I agree with @Hozington. This should be the bug on Cordova code of detecting Java version. What I did is:

  1. Keep the JDK 10
  2. Install the JDK 8
  3. Change the JAVA_HOME to the path of JDK 8, and change the path variable as well.
  4. restart the "cmd" and run cordova build again.

And the error disappeared!


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

Today I also got this error Cordova : Requirements check failed for JDK 1.8 or greater in my Mac OS while build Ionic App when I run command ionic cordova build --release android via terminal.

Below command resolve my issue :-

export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home"

Hope it will help someone in future!


MAC: Navigate to :/Library/Java/JavaVirtualMachines Make sure you are having only jdk1.8.0_201.jdk If you have many then remove other JDK


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.


I have (Open)JDK 8 and 11 installed on Windows 10 and I had the same problem. For me the following worked:

  1. Set JAVA_HOME to point to JDK 8. (Mentioned in many answers before.) AND
  2. Remove(!) JDK 11 from the PATH as it turned out that -- although displaying the JAVA_HOME path pointing to JDK 8 -- Cordova actually accessed JDK 11 that was included in the PATH, which made the Java version check fail.

If you have both jdk8 and jdk9 installed, you have to check wich version is

in the path and where JAVA_HOME is pointing to.

In the log you posted, I see that JAVA_HOME is leading to the JDK9.

modify your globel JAVA_HOME env var to target JDK8 or you can change JAVA_HOME in powershell before you use the cordova CLI if you want to use jdk8 only for cordova:

$env:JAVA_HOME="C:\Program Files\Java\jdk1.8.0_151"

**cordova build android**

The Ubuntu/Debian Linux version of this answer is to install openjdk 8 and set the default via update-alternatives


# install (open)jdk 8
sudo apt-get install -y openjdk-8-jdk

# update java compiler and set to 1.8
update-alternatives --config javac

# update java runtime (optional)
update-alternatives --config java

# Also set $JAVA_HOME and $PATH to your .bashrc (optional)
echo 'export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64' >> ~/.bashrc
echo 'export PATH="$PATH:$JAVA_HOME/bin' >> ~/.bashrc

# load in current bash session
source ~/.bashrc

I dicovered that my path environmental variable was pointing to java 1.7 while JAVA_HOME was pointing to 1.8, so i edited the path variable to 1.8 and i was fine.


It seems the Android SDK don't support Java 9. Downgrade to 8 if you dont want to go all the way back to JDK 1.8 which to me is ridiculous. JDK 8 work for me but be sure to set the JAVA_HOME environment variable to the location of your JDK installation correctly.