why do I get this? How can I fix it?
C:\\Users\\ash>java version
Error: Registry key \'Software\\JavaSoft\\Java Runtime Environment\'\\Cu
None of the above worked for me, unfortunately. The error solved when I uninstalled the old JDK versions that were installed on my computer. I did it simply with the "Uninstall or change a program" tool (under the Control Panel).
You could be using a 32 bit version of java on a 64 bit environment. Export the registry hive form HKLM\Software\JavaSoft and import into HKLM\Software\Wow6432Node\JavaSoft. For 1.6 I only needed JavaHome and RuntimeLib values.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Javasoft]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Javasoft\Java Runtime Environment]
"CurrentVersion"="1.6"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Javasoft\Java Runtime Environment\1.6]
"JavaHome"="C:\\Java\\jre"
"RuntimeLib"="C:\\Java\\jre\\bin\\client\\jvm.dll"
Removing
C:\ProgramData\Oracle\Java\javapath;
work like charm
I removed the "C:\Program Files (x86)\Heroku\bin" from PATH variable and the problem has gone. I think it is probably the Heroku require different version of Java. So check all directories in your PATH variable, remove the possible ones may have confliction.
The accepted solution for Reinstalling ALL JDKs was a bit harsh. I too experienced this problem and here is my 2 cents:
This problem started happening since I installed JDK 8 and still had JDK 6 installed. I need for different projects I'm working on.
I noticed I had both a User and a System %JAVA_HOME%
, so I removed my User %JAVA_HOME%
variable and left only the system one.
I also noticed that in my Oracle installation there was some Java executables and I believe those where the ones conflicting since both my Oracle and Java installations were in my %PATH%
variable.
I removed all Java paths from my %PATH%
Variable and only left the %JAVA_HOME%\bin
at the start of the variable for avoiding any conflicts with the Oracle installation.
Problem: We had the same problem in our Windows 2012 server. We used JAVA_HOME environmental system variable, an we used in the PATH this kind of settings: ...%JAVA_HOME%/bin;... and no other java related settings was in the PATH.
The problem was we had a space at the end of the value of the JAVA_HOME variable. Like 'C:\Program Files\Java\Jdk 1.8.0_172 ' so the %JAVA_HOME%/bin meant 'C:\Program Files\Java\Jdk 1.8.0_172 \bin'. So because the value was split by space and the system tried to find java.exe at 'C:\Program Files\Java\Jdk 1.8.0_172' where it is obviously not.
Solution was: Delete the space from the end of value of the JAVA_HOME !