Oct 16, 2009

Hadoop: Error: JAVA_HOME is not set.

If you get this when trying to use Hadoop:

$ start-dfs.sh 
starting namenode, logging to /Users/user/Applications/hadoop-0.20.1/bin/../logs/hadoop-user-namenode-merlyn.local.out
localhost: starting datanode, logging to /Users/user/Applications/hadoop-0.20.1/bin/../logs/hadoop-user-datanode-merlyn.local.out
localhost: Error: JAVA_HOME is not set.
localhost: starting secondarynamenode, logging to /Users/user/Applications/hadoop-0.20.1/bin/../logs/hadoop-user-secondarynamenode-merlyn.local.out
localhost: Error: JAVA_HOME is not set.
Then edit conf/hadoop-env.sh (I couldn't easily google this info).

Edit: I missed this: Unpack the downloaded Hadoop distribution. In the distribution, edit the file conf/hadoop-env.sh to define at least JAVA_HOME to be the root of your Java installation.

The file is helpful once you know it is relevant:
# The only required environment variable is JAVA_HOME. All others are
# optional. When running a distributed configuration it is best to
# set JAVA_HOME in this file, so that it is correctly defined on
# remote nodes.
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

2 comments:

Anonymous said...

Really, cause here's the Hadoop Quickstart page (http://hadoop.apache.org/common/docs/r0.20.0/quickstart.html):
"Unpack the downloaded Hadoop distribution. In the distribution, edit the file conf/hadoop-env.sh to define at least JAVA_HOME to be the root of your Java installation. " Definitely a hidden secret, that.

Curious Attempt Bunny said...

There it is. You're right. Thanks.