On Windows 8.1 x64, I have installed Android Studio. However, it won't start.

I keep getting error messages related to JAVA_HOME in user variables. I have installed both the jre and the jdk. When I set JAVA_HOME to either of these two paths, I still get the same message:

C:\Program Files\Java\jdk1.8.0_51\bin
C:\Program Files\Java\jre1.8.0_51\bin

I'd be grateful for some advice from anyone who has solved this problem.