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

Ali Ismail picture Ali Ismail · Jan 14, 2013 · Viewed 52.5k times · Source

I'm working with Ubuntu 12.04 LTS.

I'm going through the hadoop quickstart manual to make a pseudo-distributed operation. It seems simple and straightforward (easy!).

However, when I try to run start-all.sh I get:

localhost: Error: JAVA_HOME is not set.

I've read all the other advice on stackoverflow for this issue and have done the following to ensure JAVA_HOME is set:

In /etc/hadoop/conf/hadoop-env.sh I have set

JAVA_HOME=/usr/lib/jvm/java-6-oracle
export JAVA_HOME

In /etc/bash.bashrc I have set

JAVA_HOME=/usr/lib/jvm/java-6-oracle
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH

which java returns:

/usr/bin/java

java –version works

echo $JAVA_HOME returns:

/usr/lib/jvm/java-6-oracle

I've even tried becoming root and explicitly writing the in the terminal:

$ JAVA_HOME=/usr/lib/jvm/java-6-oracle
$ export JAVA_HOME
$ start-all.sh

If you could show me how to resolve this error it would be greatly appreciated. I'm thinking that my JAVA_HOME is being overridden somehow. If that is the case, could you explain to me how to make my exports global?

Answer

Krishna picture Krishna · Jan 22, 2013

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>