Build JAVA_HOME Error

Hi all, i have a problem in building ionic app to android:

i launch the command:

$ ionic cordova build android

and, after many steps I get:


chunk {index-69c37885-js} index-69c37885-js-es2015.js, index-69c37885-js-es2015.js.map (index-69c37885-js) 37.7 kB [rendered]
chunk {index-69c37885-js} index-69c37885-js-es5.js, index-69c37885-js-es5.js.map (index-69c37885-js) 56 kB [rendered]
chunk {cordova} cordova.js (cordova) 63.5 kB [entry] [rendered]
Date: 2020-07-22T16:31:20.198Z - Hash: 5201ed19bb967610b31c - Time: 61805ms

cordova.cmd build android
Failed to run “javac -version”, make sure that you have a JDK version 8 installed.
You can get it from the following location:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Your JAVA_HOME is invalid: C:\Program Files\Java\jdk1.8.0_261
[ERROR] An error occurred while running subprocess cordova.

** cordova.cmd build android exited with exit code 1.**

** Re-running this command with the --verbose flag may provide more information.**

Then I tried the cordova command directly but:

$ cordova.cmd build android
Failed to run “javac -version”, make sure that you have a JDK version 8 installed.
You can get it from the following location:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Your JAVA_HOME is invalid: C:\Program Files\Java\jdk1.8.0_261

I have Java 8 installed, in Win10 VM machine.
Any suggestion?