title: On Windows 8.1 "javac -version" works but Cordova doesn't recognize it
body: <p>I'm trying to set up Cordova. When I run <code>cordova build android</code> I receive the following error:</p>
  
  <pre><code>(node:6816) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Failed to run "javac -version", make sure that you have a JDK installed.
  You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.
  Your JAVA_HOME is invalid: C:\Program Files\Java\jdk1.8.0_161;C:\Program Files\Java\jdk1.8.0_161\bin
  </code></pre>
  
  <p>However I can run <code>javac -version</code> just fine.</p>
  
  <pre><code>C:\&gt;javac -version
  javac 1.8.0_161
  </code></pre>
  
  <p>I've tried to set <code>JAVA_HOME</code> in various ways: pointing to the root; pointing to the <code>bin</code> folder; set it as a User variable and also a System one; add <code>%JAVA_HOME%\bin</code> to <code>Path</code> (both for User and System) and so on.</p>
  
  <p>I've checked several articles about this issue, and they say that if I'm able to use <code>javac -version</code> then that's supposed to indicate that my environmental variables are set correctly. Even if that's the case, Cordova still doesn't seem to recognize it.</p>
  
  <h1>Update</h1>
  
  <p>Following Stephen C's instructions, I've reset my variables, yet my error still persists. As you can see in the image I can call <code>javac</code> just fine, and both <code>JAVA_HOME</code> and <code>Path</code> seem to be set in the right way. (Note that actually it is <code>%JAVA_HOME%\bin</code> and not <code>C:\Program Files\Java\jdk1.8.0_161\bin</code> in the <code>Path</code>.)</p>
  
  <p><a href="https://i.stack.imgur.com/jSqJd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jSqJd.png" alt="enter image description here"></a></p>