Cordova isn’t working with Java 9. How to fix
Did anyone try running
cordova build on a computer with Java 9? Well, I tried and got this.
Requirements check failed for JDK 1.8 or greater
Apparently, Cordova is unable to identify Java 9 is greater than Java 8. More precisely Android is not supporting Java 9 yet. Here is the problem I’m describing.
If anyone is wondering what the heck is Cordova and what is the use of it, let me quote the Wikipedia.
Anyway, I was working on a new product (More details for later). It consists of an API and mobile application. Since I never created a mobile application with native APIs before and I have only very little time period, I thought to give Cordova a try.
So what is the fix? I needed to run command
cordova build and build the app. Sadly there is no fix for Java 9 yet. Only workarounds. The most recommended way is to revert to Java 8 again. And that is exactly what I did. I reverted
Java_Home Environment Variables back to Java 8 and ran
cordova build without any issue.
I forgot to mention my Dev machine runs on Windows 10.
For Linux users, there is a bash script below. I found it from here.
The logic behind the script is running Cordova via Java 8 by setting,
JAVA_HOME variables explicitly. I did not test it so I can’t vouch for the success or failure of this script.
Do you have any workarounds or suggestions for “Cordova isn’t working with Java 9”? I love to hear. Please leave a comment below.
Photo by William Hook on Unsplash