Hadoop: «ERROR : JAVA_HOME is not set»

koukou picture koukou · Jan 11, 2012 · Viewed 127.1k times · Source

I'm trying to install Hadoop on Ubuntu 11.10. I set the JAVA_HOME variable in the file conf/hadoop-env.sh to:

# export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk

and then I execute these commands (Standalone Operation):

$ mkdir input 
$ cp conf/*.xml input 
$ bin/hadoop jar hadoop-examples-*.jar grep input output 'dfs[a-z.]+' 
$ cat output/*

but I have the following error when executing the third command:

ERROR : JAVA_HOME is not set

Is the JAVA_HOME variable not set correctly?

Answer

user1489515 picture user1489515 · Jun 28, 2012

Make sure that you have removed the comment tag and changed your JAVA_HOME in the hadoop-env.sh as well as the appropriate .bashrc and/or .profile:

# export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk

should be

export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk

You can set your JAVA_HOME and PATH for all users (make sure you haven't previously set this to the wrong path) in /etc/profile.

Also, don't forget to activate the new change by logging-out/in or by executing source /etc/profile.