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

There it is. You're right. Thanks.

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

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.

Thanks it helped.

thx it helped...

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

really thank you very very much

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

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

Thank you

Thank you