This issue is annoying when dealing with multiple JDKs for developing on Windows 10 (I couldn't make use of the OS system path change as suggested here).
As a partial answer (since this might not be intended as 'properly' installed) I'm doing quite fine using Cygwin to switch JAVA_HOME and run Maven builds with different JDKs (1.7,1.8) installed (via Oracle installers).
So if you have Cygwin installed (or can install and use it) and willing to use JAVA_HOME env variable (useful with Maven as in this example below) you could do like this (BUT be aware of the 'trick' in the answer at link 1 and adjust your local paths accordingly):
export JAVA_HOME=/cygdrive/c/Progra~1/Java/jdk1.8.0_74
(mvn --version output)
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5;
2015-11-10T17:41:47+01:00) Maven home:
C:\Work2\bin\apache-maven-3.3.9-bin\apache-maven-3.3.9 Java version:
1.8.0_74, vendor: Oracle Corporation Java home: C:\Progra~1\Java\jdk1.8.0_74\jre Default locale: it_IT, platform
encoding: Cp1252 OS name: "windows 10", version: "10.0", arch:
"amd64", family: "dos"
export JAVA_HOME=/cygdrive/c/Work2/bin/Java/jdk1.7.0_79_64bit/
(mvn --version output)
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5;
2015-11-10T17:41:47+01:00) Maven home:
C:\Work2\bin\apache-maven-3.3.9-bin\apache-maven-3.3.9 Java version:
1.7.0_79, vendor: Oracle Corporation Java home: C:\Work2\bin\Java\jdk1.7.0_79_64bit\jre Default locale: it_IT,
platform encoding: Cp1252 OS name: "windows 8.1", version: "6.3",
arch: "amd64", family: "windows"
https://stackoverflow.com/questions/14567191/export-java-home-with-spaces-in-cygwin