如何修复错误:在“(null)”中找不到所需版本的 Java(TM) 2 运行时环境

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22639865/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 17:01:08  来源:igfitidea点击:

How to fix error: could not find the required version of the Java(TM) 2 runtime environment in '(null)'

javainstallation

提问by mitchj

I have researched this and none of the solutions that I have seen have fixed my error.

我已经对此进行了研究,但我所看到的所有解决方案都没有解决我的错误。

What is happening is I tried to install Java EE version got the above error and then found out that I must install Java SE first. So I installed Java SE and set the JAVA_HOME variable to C:\Program Files\Java\jdk1.8.0 which is where I installed my JDK. I also put C:\Program Files\Java\jdk1.8.0\bin in my PATH variable. Still not working. I also tried the JAVA_HOME variable with C:\Program Files\Java\jdk1.8.0\bin and that didn't work. I also tried installing without the PATH variable being updated to where I put my JDK.

发生的事情是我尝试安装 Java EE 版本时出现上述错误,然后发现我必须先安装 Java SE。所以我安装了 Java SE 并将 JAVA_HOME 变量设置为 C:\Program Files\Java\jdk1.8.0,这是我安装 JDK 的地方。我还将 C:\Program Files\Java\jdk1.8.0\bin 放在我的 PATH 变量中。还是行不通。我还用 C:\Program Files\Java\jdk1.8.0\bin 尝试了 JAVA_HOME 变量,但没有奏效。我还尝试在没有将 PATH 变量更新到我放置 JDK 的位置的情况下进行安装。

I'm really getting confused as to why this is happening. I've had Java before and I don't recall having this much trouble installing it.

我真的很困惑为什么会这样。我以前用过 Java,我不记得安装它有这么多麻烦。

PS I don't install from the command line I just click the download icon in Firefox and then click the download.

PS 我不从命令行安装我只是单击 Firefox 中的下载图标,然后单击下载。

采纳答案by Ewald

Uninstall everything, all of it.

卸载一切,全部。

Then go to your Program Files folder (and (x86) folder if on a 64bit Windows) and physically remove any Java folders.

然后转到您的 Program Files 文件夹(如果在 64 位 Windows 上,则为 (x86) 文件夹)并物理删除所有 Java 文件夹。

Reinstall Java SE and then the EE packages. Sometimes Windows appears to get a bit confused and you need to help it figure out what to do.

重新安装 Java SE,然后重新安装 EE 包。有时 Windows 似乎有点困惑,您需要帮助它弄清楚该怎么做。

回答by Mobold

Try running the installer at your commandline and pass the path of the JRE instead of the JDK.

尝试在命令行中运行安装程序并传递 JRE 而不是 JDK 的路径。

For Example:

例如:

java_ee_sdk7-windows.exe -j "C:\Program Files\Java\jre8" 

回答by vekat

If you want to uninstall, go to the glassfish folder and open the command prompt, then type:

如果要卸载,请转到 glassfish 文件夹并打开命令提示符,然后键入:

uninstall.exe -j <The path to your JRE>

回答by arlokan

This was happening to me when I tried to run the Java EE installer. What I did, was to download from Oracle a Java EE version which didn't include the JDK, because it was already installed in my system. Problem solved!

当我尝试运行 Java EE 安装程序时,这发生在我身上。我所做的是从 Oracle 下载一个不包含 JDK 的 Java EE 版本,因为它已经安装在我的系统中。问题解决了!

回答by Ekhtiar

I had the exact same problem and even downloading the version without JDK didn't help! I simply installed it from the terminal with passing the JRE For Example:

我遇到了完全相同的问题,甚至下载没有 JDK 的版本也无济于事!我只是通过传递 JRE 从终端安装它例如:

java_ee_sdk7-windows.exe -j "C:\Program Files\Java\jre7"

java_ee_sdk7-windows.exe -j "C:\Program Files\Java\jre7"

and it worked like a charm!

它就像一个魅力!

回答by Anders B

  1. Open regedit.
  2. goto :HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\
  3. set CurrentVersion to desired JDK version.
  4. Check JavaHome and RuntimeLib path's for selected jdk version folder
  1. 打开注册表。
  2. 转到:HKEY_LOCAL_MACHINE\Software\JavaSoft\Java 运行时环境\
  3. 将 CurrentVersion 设置为所需的 JDK 版本。
  4. 检查所选 jdk 版本文件夹的 JavaHome 和 RuntimeLib 路径

Check JavaHome and RuntimeLib path's for selected jdk version folder example: "HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\1.7".

检查所选 jdk 版本文件夹示例的 JavaHome 和 RuntimeLib 路径:“HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\1.7”。

example:

例子:

  • JavaHome=C:\Program Files (x86)\Java\jdk1.7.0_79
  • RuntimeLib=C:\Program Files (x86)\Java\jdk1.7.0_79\jre\bin\server\jvm.dll
  • JavaHome=C:\Program Files (x86)\Java\jdk1.7.0_79
  • RuntimeLib=C:\Program Files (x86)\Java\jdk1.7.0_79\jre\bin\server\jvm.dll

Source: http://tech-read.com/2009/05/19/how-to-solve-error-could-not-find-java-runtime-2-environment-while-opening-an-ide/

资料来源:http: //tech-read.com/2009/05/19/how-to-solve-error-could-not-find-java-runtime-2-environment-while-opening-an-ide/

回答by laf8

I had the same problem but an additional step was required in order to install using the command line. In the command window (on my Windows 10 laptop) I had to use:

我遇到了同样的问题,但需要额外的步骤才能使用命令行进行安装。在命令窗口中(在我的 Windows 10 笔记本电脑上),我必须使用:

cmd /d

to tell the cmd window to ignore registry AutoRun commands before the java installation executable would run. After using cmd /d, and changing to the directory where the .exe file was at, the following worked:

告诉 cmd 窗口在 java 安装可执行文件运行之前忽略注册表 AutoRun 命令。使用 cmd /d 并切换到 .exe 文件所在的目录后,以下操作有效:

java_ee_sdk-6u4-jdk7-windows-x64.exe -j "%JAVA_HOME%"

Where JAVA_HOME is a system environment variable pointing to an existing JDK installation (C:\Program Files\Java\jdk1.8.0_65).

其中 JAVA_HOME 是指向现有 JDK 安装 (C:\Program Files\Java\jdk1.8.0_65) 的系统环境变量。

回答by Shadyar

These points may be helpful.

这些要点可能会有所帮助。

  1. java EE SDK7contains glassfish v4.0and it compatible with JDK6and JDK7.

  2. java EE SDK8contains glassfish v5.0, it compatible with only JDK7 and JDK8, not JDK9 or beyond.

  3. So environment variable JAVA_HOMEhas to point to the root directory of one of the mentioned JDK. and %JAVA_HOME%\binshould be added to environment variable path

  4. Despite having followed all of the above, setup of java EE SDK7gets error:
  1. java EE SDK7containsglassfish v4.0并且它与JDK6and兼容JDK7

  2. java EE SDK8contains glassfish v5.0,它只兼容JDK7 and JDK8,不兼容JDK9 或更高版本。

  3. 因此环境变量JAVA_HOME必须指向上述JDK. 并且%JAVA_HOME%\bin应该添加到环境变量路径中

  4. 尽管遵循了上述所有内容,但设置java EE SDK7仍会出错:

could not find the required version of the Java(TM;

找不到所需版本的 Java(TM;

as Bakudan and laf8 said,
open cmd using run, with /d /a options as followed.

正如 Bakudan 和 laf8 所说,
使用 run 打开 cmd,使用 /d /a 选项如下。

cmd /d /a

and next run SDK7-setup with -j option like this command

然后像这个命令一样使用 -j 选项运行 SDK7-setup

sdk7.exe -j "%JAVA_HOME%"

note that %JAVA_HOME%enclosed BY ""

请注意用%JAVA_HOME%“”括起来