I tried the steps mentioned by @bcmoney but for me the current version was already set to the latest version. In my it was Java8.
I had various versions of java installed (java6, java7 and java8). I got the same error but instead of 1.5 and 1.7 i got 1.7 and 1.8. I uninstalled java6 on my windows 8.1 machine. After which i tried java -version in command prompt and the error did not appear.
I am not sure whether this is the right answer but it worked for me so i thought it would help the community too.