简体   繁体   中英

“Could not find Java SE Runtime Environment.” after installing Java

I was trying to set up Eclipse for trying my hand at Android app dev. I downloaded Eclipse and tried to run it... discovered I needed Java JDK. Googled and found JDK 7u40 (jdk-7u40-windows-x64.exe) and installed it. The install seemed to have gone dandy but when I tried to run Eclipse I got an error as well as if I try java version in cmd.

Error: opening registry key 'Software\JavaSoft\Java Runtime Environment'
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.

I went to regedit, HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft and Java Runtime Environment doesn't exist in there. Seems like this is more of a symptom than the root cause of my problems.

My PATH looks like

PATH=C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program File
s (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Window
s;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Progra
m Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Window
s Live\Shared;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\AIR\bin;C:
\Program Files (x86)\nodejs\;C:\SDK\Android\tools;C:\SDK\Android\platform-tools;
C:\SDK\ANT\apache-ant-1.9.2\bin;C:\Program Files\Java\jdk1.7.0_40\bin\

%JAVA_HOME% = C:\\Program Files\\Java\\jdk1.7.0_40

I'm running Windows 7 Pro 64-bit

I did already read through Error when checking Java version: could not find java.dll and linked materials

Finally found a forum post that outlined what the registry is supposed to look like when not broken.

  1. Added key HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment
  2. Added String Value CurrentVersion = 1.7
  3. Added key HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.7
  4. Added String Value JavaHome = C:\\Program Files\\Java\\jre7

Running cmd java -version and Eclipse now works

You can tell eclipse which JRE to use in the eclipse.ini. If you've installed bundles that require 1.7 in your IDE you will need a 1.7 JRE to run the IDE itself. add the below lines to eclipse.ini file

-startup plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
-vm C:\\Program Files (x86)\\Java\\jre7\\bin\\javaw.exe
.
.
.

A 32 bit eclipse cannot load a 64 bit Java Runtime Environment.

Try again with a 32 bit Java Runtime Environment, or (preferred) upgrade your Eclipse to a 64 bit version.

Also, a good idea (from the command line)

C:> java -version

Which should give you details about your JVM. If it doesn't work, focus on fixing that before fixing Eclipse's use of Java.

You can try reinstall your JDK. I've had this problem because I uninstalled so many java things in my PC. And when I open Eclipse, the error occurred.

As most of us suggested to edit the registry, but in case you don't want to, because it's risky or you don't have permissions to do so, you can uninstall all the java version, restart your machine, install desired java version, make sure to set path settings. This worked for me.

I was getting the same error (below) for Oracle when I clicked on a G2 application.

Error: opening registry key 'Software\\JavaSoft\\Java Runtime Environment'

Error: could not find java.dll

Error: Could not find Java SE Runtime Environment.

I restarted the machine, still the same.

I reinstalled the app (which includes Oracle), still the same.

I checked all the suggested registry settings as suggested and my registry was fine.

I checked the shortcut path and it fires up javaw.exe with a string following within the shortcut. I navigated to the G2 program files and I tried clicking in the javaw.exe directly within the application folder and got the same error.

I did some research into this and found that Java has a Javaw.exe within the following path:

C:\\Program Files\\Java\\jre7\\bin\\javaw.exe

I navigated to the path and clicked on this javaw.exe file and didn't get any errors

I renamed the javaw.exe in the G2 app to javaw_old.exe and then copied and pasted the javaw.exe file from the above path into my app folder. Files side by side, you could see a file size difference and the date was 8 months difference. The newer and larger file being the one in the latest Java install folder.

Clicked on the G2 shortcut and the application opened without any errors.

If you have the same issue as me where everything Java is okay and your still getting the error, try find the java(.exe) file that your app is erroring on, rename it and copy and paste the same file from your Java folder (C:\\Program Files\\Java\\jre7\\bin) to the same folder your app's Java file is located.

I hope this helps someone.

Just reinstall your JRE. You will probably need to restart a computer after uninstalling.

Having both 1.7 and 1.8 caused me this problem. While uninstalling 1.8 some of the 1.7 registry keys were removed I guess. I was missing the key Java Runtime Environment and JavaHome String. Uninstalling all the versions of JDK and reinstalling the 1.7(update 80) solved me the problem.

I had exactly the same problem and exactly same set of errors. That was because my registry key Java Runtime Environment was missing altogether. I did not have any conflicting 32/64 bit settings or any conflicting 1.7/1.8 settings.

All I did was install an update provided by Java and my settings went haywire. What I did to resolve was, instead of updating registry entries myself, I simply did an uninstall and fresh install of JRE and everything was back to normal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM