Windows 10:
Android Studio -> File -> Other Settings -> Default Project Structure... -> JDK location:
copy string shown, such as:
C:\Program Files\Android\Android Studio\jre
In file locator directory window, right-click on "This PC" ->
Properties -> Advanced System Settings -> Environment Variables... -> System Variables
click on the New... button under System Variables, then type and paste respectively:
.......Variable name: JAVA_HOME
.......Variable value: C:\Program Files\Android\Android Studio\jre
and hit OK buttons to close out.
Some installations may require JRE_HOME to be set as well, the same way.
To check, open a NEW black console window, then type echo %JAVA_HOME%
. You should get back the full path you typed into the system variable. Windows 10 seems to support spaces in the filename paths for system variables very well, and does not seem to need ~tilde eliding.