I don't have windows 8, but you can try this:
Install latest version of JDK
Latest version of JRE
Notice that if you are running 32 bit browser then you must have x86 bit Java installed. So all those using x64 bit OS must install x86
bit JRE if they are using 32 bit browser as in my case this was the
Both x64 and x86 JAVA can be installed simultaneously. So better install both! (i have both installed)
Now, Add the path of java compiler to the environment variable as shown below:
Open Advance System Settings > Environment Variables> System Variables.
Click New (if it doesn’t exist else Edit) : CLASSPATH (variable name), %JAVA_HOME%\jre\lib; (variable value),
Click New : JAVA_HOME (name), C:\Program Files\Java\jdk1.7.0 (value).
Click Edit in Path: in value add: %JAVA_HOME%\bin;
Save and exit.
Note ‘ ; ‘ separates one path with other just like ‘ . ‘ denotes the end of a line.’
Hope this solves your problem. Enjoy java in windows 8.