JAVA_HOME 设置不正确 – 在 Windows 10 上安装 Hadoop

huangapple go评论71阅读模式
英文:

JAVA_HOME is set incorrectly -- Hadoop on Windows 10

问题

Context: 我正在尝试在我的 Windows 10 机器上安装 Hadoop。我已经按照这里的说明进行操作,但在完成过程中遇到了很多困难。我一直遇到以下错误:

> 系统找不到指定的路径。
错误:JAVA_HOME 设置不正确。
请更新 C:\Users\eric\Downloads\hadoop-3.1.4.tar\hadoop-3.1.4\hadoop-3.1.4\etc\hadoop\hadoop-env.cmd。' -Dhadoop.security.logger' 不是内部或外部命令,也不是可运行的程序或批处理文件。

当我检查 Java 版本时,我得到了以下输出,所以我确定 Java 已经安装好了。

C:\Java\bin>java -version
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

从上述错误中我可以推断出,我设置的 JAVA_HOME 环境变量中存在问题。但我真的不清楚为什么错误消息中引用了那个目录,因为当我在终端中执行 echo %JAVA_HOME% 时,我得到的是 C:\Java\bin,这是环境变量的路径(如此处推荐的这里)。

Question: 我猜想无法找到或丢失了 jdk 文件,或者可能是其他问题。我如何解决这些问题?我在哪里可以找到这个 JDK 文件(在视频的 11:55 处显示的 jdkl.8.0_241 文件),因为它似乎不在 JDK 下载的 bin 文件夹中?请帮忙解决。这个问题并不是重复的,因为问题似乎与 JDK 文件更密切相关。

英文:

Context: I am trying to install Hadoop on my Windows 10 machine. I've followed the directions here and I'm having a lot of difficulty completing the process. I keep raising the following error:

> The system cannot find the path specified.
Error: JAVA_HOME is incorrectly set.
Please update C:\Users\eric\Downloads\hadoop-3.1.4.tar\hadoop-3.1.4\hadoop-3.1.4\etc\hadoop\hadoop-env.cmd'-Dhadoop.security.logger' is not recognized as an internal or external command,
operable program or batch file.

When I check the version of Java I get the following, so I know for sure Java has been installed.

C:\Java\bin>java -version
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

I gather from the above error there's an issue with the path in the environment variable I've set for JAVA_HOME. I'm really unclear why the error refers to that directory in the message because when I echo %JAVA_HOME% at terminal I get C:\Java\bin as the environment variable path (as recommended here).

Question: I'm guessing the jdk file cant be found/is lost or something else. How do I resolve these issues? And where can I find this JDK file (the jdkl.8.0_241 file shown @11:55 in the video) because it doesnt appear to be in the bin folder of the JDK download? Please help. This question is NOT a duplicate, because the issue seems to be more closely related to the JDK file.

答案1

得分: 0

JAVA_HOME 应该指向 Java JDK 的根目录,并且应在 环境变量 中进行指定。设置完此值后,需要重新启动终端/应用程序/控制台/集成开发环境/命令提示符,以使新值生效。

如果你简单地执行:java --version,它会使用在你的 PATH 中找到的第一个 java.exe 版本。JAVA_HOMEPATH 中的 Java 版本之间没有任何关系。

JAVA_HOME 可以被指定为例如:c:/java/jdk9,而你的路径包括 c:/java/jdk8/bin。在这种情况下,java --version 将给出 1.8.x.x

JAVA_HOME 被进程用于派生到新子进程,然后使用该 JAVA_HOME 值。

在你的情况下,可能在调用 hadoop-env.cmd 时只是缺少一个空格或在其后缺少一个空格?(根据当前信息不太清楚)

英文:

JAVA_HOME should be point to the root directory of a Java JDK and should be specified in the environment variables. After setting this value a restart of the terminal/application/console/IDE/command-prompt is required to make the new value active.

If you simple give: java --version it use the first java.exe version found on your PATH. JAVA_HOME and the PATH java version don't have any relation with each other.

JAVA_HOME can be specified for example to: "c:/java/jdk9" and your path includes "c:/java/jdk8/bin". In this situation java --version will give you 1.8.x.x.

JAVA_HOME is used by processes that forks to a new subproces and then used that JAVA_HOME value.

In your situation there is probably only a spacer missing in/after the call to hadoop-env.cmd ?? (not clear with the current info)

huangapple
  • 本文由 发表于 2020年10月20日 04:27:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/64434706.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定