On my Windows 7 machine, it was resolved by doing the following:
In the START menu type "regedit" to open the Registry
Go to "HKEY_LOCAL_MACHINE" on the left-hand side registry explorer/tree menu
Click on "SOFTWARE" within the "HKEY_LOCAL_MACHINE" registries
Click on "JavaSoft" within the "SOFTWARE" registries
Click on "Java Runtime Environment" within the "JavaSoft" list of registries
Highlight "CurrentVersion" (should see it in the main registry key explorer window on the right)
Alter version to "1.7"
That is all must work. Short of that, in case you've meanwhile attempted some other guides and/or messed up your registries, the most definite way to deal with the issue is to delete all previous versions of Java (employing "Programs and Features" uninstall process) and then re-install only the version you want to perform with. I'd indicate the distribution site at: http://java.com (as it generally has the most stable version)
I had various JDK from 1.5 to 1.7 installed on my PC. I had a require to learn JDK1.8 so installed and my prior versions of Eclipse (depended on earlier versions of JDK) and I got errors launching my Eclipse IDE, on the command line I attemted to check the Java Version and got the error below,
Registry key 'Software\JavaSoft\Java Runtime Environment\CurrentVersion'
has value '1.8', but '1.6' is required.
Error: could not find java.dll
Error: could not find Java SE Runtime Environment.
from the PATH variable and moved %JAVA%\bin to the begin of the PATH variable, that resolved the issue for me.
set PATH=c:\Program Files\Java\jdk1.6.0_45\bin;%PATH%
this will perform in case you are working on command prompt
Furthermore, you may follow these steps :
Fixed JAVA_HOME to jdk[without bin folder]
Fixed PATH as %JAVA_HOME%/bin;
Place java.exe , javaw.exe & javaws.exe to C:\ProgramData\Oracle\Java\javapath [I was having problem here].
double click on the java.exe
Further check and edit the registry value for JAVA current version if necessary.
After attempting more than hundred of tricks, finally got success.
I removed all
Windows\SysWOW64 folder. [Try step 2 if you have x64 system (Win 7 64 bits)]
In my instance (Windows 7 64-bit), I only did the following:
Removed the reference to C:\ProgramData\Oracle\Java\javapath; from the Path environment variable
Removed files java, javaw and javaws from the C:\Windows\System32 folder
Laterly, I closed all open command line consoles, reopened them and ran java -version.