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).

Hadoop: The Definitive GuideHadoop: The Definitive Guide  
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

12 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.

Anonymous said...

Thanks dude. Anyone else who finds this, dont forgoet on cygwin system, its forward slash not back slash.

export JAVA_HOME=C:/developer/Java/jdk1.6.0_20

Anonymous said...

As I was installing machines one by one, sometimes I forgot to execute this step. I banged my head for quite a while, searched a lot. This page helped me to spot the error immediately. Thanks for that.

Gagandeep Singh said...

Thanks it helped.

MAHESHWARI SAURABH said...

thx it helped...

Srikant......MIT-Manipal said...

I did change the changes in hadoop/conf hadoop-en.sh file. But still while starting the nodes..it is not starting datanode and secondary nodes..localhost: Error: JAVA_HOME is not set

تنمية said...

really thank you very very much

Sridhar Sarnobat said...

Thank you. I was blaming myself for using ZSH all this time :)

Sridhar Sarnobat said...

Thank you. I was blaming myself for using ZSH all this time :)

Anonymous said...

Thank you

Anonymous said...

Thank you