Same issue, after immense frustration and blind dead end suggestions I managed to install it on my friends windows 7 machine using the following in the environment variables.
CLASSPATH %HOME_JAVA%\jre\lib
ANDROID_STUDIO_JDK C:\Program Files\Java\jdk1.8.0_40
JAVA_HOME C:\Program Files\Java\jdk1.8.0_40
JRE_HOME C:\Program Files\Java\jdk1.8.0_40
JDK_HOME C:\Program Files\Java\jdk1.8.0_40
Plus: removed old paths and links to Java, removed old Registry paths
However I need to install it on my windows 7 machine and windows Vista and I have had no luck.
Additionally I have tried placing a "\" at the end of the paths, the back and forward clicking etc, it all fails. I have changed to a 32bit version of Java JDK.
The major issue I have is that all the answers seem to be hacks and guessing, not just in this forum, but all the forums. No one really knows the issue. I'd pay someone to tell me exactly step by step what to do ,and why it will work, and have it succeed more importantly.
The odd part is that Google have known about this for years and have zero attempt to fix, even their dialogue box to browse to the Java path fails to work.
I was most hopeful about this ANDROID_STUDIO_JDK as a new environment variable, but it too fails to work.
NOTE: Google suggest you open up a command dos window and use this commend
javac -version
and thats a great suggestion, its lets you know that your Java JDK is properly installed, you may need to reboot as some Java commands are memory resident.
I hope what I posted can help someone. I am going back to looking for solutions, any help will be appreciated.