(node:2864) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejec
tion id: 1): CordovaError: Failed to find 'JAVA_HOME' environment variable. Try
setting it manually.
(node:2864) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre
cated. In the future, promise rejections that are not handled will terminate the
Node.js process with a non-zero exit code.
Make sure that in a new console window the output of echo %JAVA_HOME% is really “C:\Program Files\Java\jdk1.8.0_40 or up-to-date version” so you know your changes of the environment variables are in effect.
I’m also getting the same error on linux mint. I have checked for all environment variables and they’re okay. when I echo JAVA_HOME in my terminal it shows the correct path.
Sorry, can’t help you because you seem to use a different OS than Windows which is what I use.
On Windows (10) this is what you do:
right click This PC and click properties (this will bring you to Control Panel\All Control Panel Items\System)
On the left menu click Advanced System Settings.
You’ll get this window
click on Environment Variables
There’s two things we need to do here. First one is to add a new variable (user or system doesn’t matter as far as I know, I have it on both just in case) called JAVA_HOME with your Java folder as value and click OK
You find a variable called Path and click Edit
From there you tap New and add your bin folder from the Java folder. For me that is C:\Program Files\Java\jdk1.8.0_144\bin and click OK. Now you want to move that folder to the top using the Move Up button
Open CMD and run refreshenv
Try the command java -version, if you have the correct output you should be good now.
Thanks Strinix for your reply. Another question, how did you managed to install the 1.8 JDK? I browsed in the Java Download page and it only shows the latest version.
1.8 version whould be a legacy or LTS version of Java JDK?