hadoopjava-homeappletviewer

Hadoop: JAVA_HOME is not set


Like everyone else in the world, I'm following this hadoop tutorial. I get to the point where I format HDFS, and I get this:

user@linux01:~$ sudo $HADOOP_INSTALL/bin/hadoop namenode -format
Error: JAVA_HOME is not set.

Well that's funny, I set JAVA_HOME in my /etc/profiles.

user@linux01:~$ tail -n 4 /etc/profile
export JAVA_HOME=/usr/local/jdk1.6.0_32/bin
export JDK_HOME=$JAVA_HOME
export PATH=$PATH:/usr/local/jdk1.6.0_32/bin
export HADOOP_INSTALL=/usr/local/hadoop/hadoop-1.0.3

Did I mess that up somehow?

user@linux01:~$ echo $JAVA_HOME
/usr/local/jdk1.6.0_32/bin
user@linux01:~$ ls $JAVA_HOME
appletviewer  extcheck       jar        javac    and so forth...

Seems to work. Maybe it absolutely has to be set in my hadoop-env.sh?

# The java implementation to use.  Required.
export JAVA_HOME=$JAVA_HOME

Lazy, yeah, but I still get "JAVA_HOME is not set" with or without this comment. I'm running low on ideas. Anyone see anything I'm missing?


Solution

  • Thank you @Chris Shain and @Chris White for your hints. I was running hadoop as su, and su doesn't automatically know about the environmental variables I set. I logged in as my hadoop user (I had chown'd the hadoop install directory to this user), and was able to format the hdfs.

    Secondary problem: When I tried to start Hadoop, NameNode and JobTracker started successfully but DataNode, SecondaryNameNode, and TaskTracker failed to start. I dug in a little bit. NameNode and JobTracker are started via hadoop-daemon.sh, but DataNode, SecondaryNameNode, and TaskTracker are started by hadoop-daemon*s*.sh. The resolution here was to properly set JAVA_HOME in conf/hadoop-env.sh.