Working With Hadoop: localhost: Error: JAVA_HOME is not set Working With Hadoop: localhost: Error: JAVA_HOME is not set hadoop hadoop

Working With Hadoop: localhost: Error: JAVA_HOME is not set


I am using hadoop 1.1, and faced the same problem.

I got it solved through changing JAVA_HOME variable in /etc/hadoop/hadoop-env.sh as:

export JAVA_HOME=/usr/lib/jvm/<jdk folder>


The way to solve this problem is to export the JAVA_HOME variable inside the conf/hadoop-env.sh file.

It doesn't matter if you already exported that variable in ~/.bashrc, it'll still show the error.

So edit conf/hadoop-env.sh and uncomment the line "export JAVA_HOME" and add a proper filesystem path to it, i.e. the path to your Java JDK.

# The Java implementation to use. Required.
export JAVA_HOME="/path/to/java/JDK/"


Ran into the same issue on ubuntu LTS 16.04. Running bash -vx ./bin/hadoop showed it tested whether java was a directory. So I changed JAVA_HOME to a folder and it worked.

++ [[ ! -d /usr/bin/java ]]++ hadoop_error 'ERROR: JAVA_HOME /usr/bin/java does not exist.'++ echo 'ERROR: JAVA_HOME /usr/bin/java does not exist.'ERROR: JAVA_HOME /usr/bin/java does not exist.

So I changed JAVA_HOME in ./etc/hadoop/hadoop-env.sh to

export JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre/

and hadoop starts fine. This is also mentioned in this article.