[Solved] Hadoop on Windows – “Error JAVA_HOME is incorrectly set.”

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.1confhadoop-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:Javajdk1.0.8_51

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

How could it be that my JAVA_HOME is incorrectly set?

Solution #1:

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

Respondent: Mohamed F

Solution #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 FilesJavajdk1.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~1JavaJDK18~1.0_7)
  3. in the file “hadoop-env.cmd”, change the line “JAVA_HOME=%JAVA_HOME%” with “JAVA_HOME=C:PROGRA~1JavaJDK18~1.0_7”.
  4. run again the file “hadoop-env.cmd” and it will work correctly.
Respondent: Mondher Sendi

Solution #3:

 set JAVA_HOME=C:Program FilesJavajdk1.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~1Javajdk1.8.0_131

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

Respondent: Jabir

Solution #4:

Use
“%JAVA_HOME%” in confhadoop-env.cmd

Respondent: nav3916872

Solution #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

Respondent: Sree Ram Iyer

Solution #6:

if your java environment path contains space, such as “C:Program Filesjavaxxxxx” , the word ?Program Files? contains a space, so CMD can’t identificate

this is the right answer

Respondent: PeaSir

Solution #7:

in hadoop-config.xml? the logic is

if not exist %JAVA_HOME%injava.exe (
echo Error: JAVA_HOME is incorrectly set.
echo Please update %HADOOP_HOME%confhadoop-env.cmd
goto :eof
)

if your java environment path contains space, such as “C:Program Filesjavaxxxxx” , the word ?Program Files? contains a space, so CMD can’t identificate

SO your can change the path instead.

Respondent: iron.root

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.