Hadoop on Windows - “Error JAVA_HOME is incorrectly set.”

你说的曾经没有我的故事 提交于 2021-01-21 07:11:07

问题


I'm trying to get Hadoop running 'Local Mode' on my Windows machine. I've been using this guide: http://hadoop.apache.org/docs/r1.2.1/single_node_setup.html

When I run the command: bin/hadoop, I get the following error message:

Error: JAVA_HOME is incorrectly set. Please update C:...\hadoop-2.7.1\conf\hadoop-env.cmd

Inside hadoop-env.cmd, I have the line: set JAVA_HOME=%JAVA_HOME%

When I type echo %JAVA_HOME% at the command line I get: C:\Java\jdk1.0.8_51

Even if I change the line in hadoop-env.cmd to: set JAVA_HOME=C:\Java\jdk1.0.8_51 I get the same error...

How could it be that my JAVA_HOME is incorrectly set?


回答1:


If your JAVA_HOME path contains spaces, you must use the Windows 8.3 Pathname




回答2:


like the other answers, your java environment path must not contain space. The solution is as follows:

  1. In the cmd line, charge the directory that contain the jdk (in my case C:\Program Files\Java\jdk1.8.0_73).
  2. execute the following line "for %I in (.) do echo %~sI" to display the short name of your installed jdk (in my case C:\PROGRA~1\Java\JDK18~1.0_7)
  3. in the file "hadoop-env.cmd", change the line "JAVA_HOME=%JAVA_HOME%" with "JAVA_HOME=C:\PROGRA~1\Java\JDK18~1.0_7".
  4. run again the file "hadoop-env.cmd" and it will work correctly.



回答3:


 set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131\

Above configuration was throwing same error as yours. I updated above with below in hadoop-env.cmd which is infact SFN

set JAVA_HOME=C:\Progra~1\Java\jdk1.8.0_131\

This allowed me to change/have different java version than that of system.




回答4:


Use "%JAVA_HOME%" in conf\hadoop-env.cmd




回答5:


Try removing @ from @rem in hadoop-env.cmd and set JAVA_HOME=%JAVA_HOME%

rem The java implementation to use.  Required.

set JAVA_HOME=%JAVA_HOME%

Then try running hdfs namenode -format

This solution worked for me




回答6:


if your java environment path contains space, such as "C:\Program Files\java\xxxxx" , the word 《Program Files》 contains a space, so CMD can't identificate

this is the right answer




回答7:


in hadoop-config.xml, the logic is

if not exist %JAVA_HOME%\bin\java.exe ( echo Error: JAVA_HOME is incorrectly set. echo Please update %HADOOP_HOME%\conf\hadoop-env.cmd goto :eof )

if your java environment path contains space, such as "C:\Program Files\java\xxxxx" , the word 《Program Files》 contains a space, so CMD can't identificate

SO your can change the path instead.



来源:https://stackoverflow.com/questions/31621032/hadoop-on-windows-error-java-home-is-incorrectly-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!