Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hadoop: «ERROR : JAVA_HOME is not set»

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?

like image 317
koukou Avatar asked Jan 11 '12 21:01

koukou


People also ask

What happens if JAVA_HOME is not set?

If any program that requires a Java runtime fails to find the JAVA_HOME environment variable upon startup, or if the JAVA_HOME environment variable is misconfigured, it will result in some of the following error messages to be displayed: A Java installation exists but JAVA_HOME has been set incorrectly.

How do you fix error JAVA_HOME is not set and no Java command could be found in your path?

Download Liberica JDK and on installation it will automatically set JAVA_HOME environment variable. Now you just go to Android Studio -> Project Structure -> SDK -> Point all jdk path to liberica jdk installation directory and apply. You are done. Just restart android studio and gradle command will work.

How do you check JAVA_HOME path is set or not?

Verify JAVA_HOMEOpen a Command Prompt window (Win⊞ + R, type cmd, hit Enter). Enter the command echo %JAVA_HOME% . This should output the path to your Java installation folder. If it doesn't, your JAVA_HOME variable was not set correctly.


2 Answers

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.

like image 113
user1489515 Avatar answered Oct 08 '22 13:10

user1489515


You should set JAVA_HOME in the hadoop-env.sh file also which is in the Hadoop configuration directory. By default the JAVA_HOME setting line is commented.

like image 21
nantitv Avatar answered Oct 08 '22 15:10

nantitv