Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Working With Hadoop: localhost: Error: JAVA_HOME is not set

I'm working with Ubuntu 12.04 LTS.

I'm going through the hadoop quickstart manual to make a pseudo-distributed operation. It seems simple and straightforward (easy!).

However, when I try to run start-all.sh I get:

localhost: Error: JAVA_HOME is not set. 

I've read all the other advice on stackoverflow for this issue and have done the following to ensure JAVA_HOME is set:

In /etc/hadoop/conf/hadoop-env.sh I have set

JAVA_HOME=/usr/lib/jvm/java-6-oracle export JAVA_HOME 

In /etc/bash.bashrc I have set

JAVA_HOME=/usr/lib/jvm/java-6-oracle export JAVA_HOME PATH=$PATH:$JAVA_HOME/bin export PATH 

which java returns:

/usr/bin/java 

java –version works

echo $JAVA_HOME returns:

/usr/lib/jvm/java-6-oracle 

I've even tried becoming root and explicitly writing the in the terminal:

$ JAVA_HOME=/usr/lib/jvm/java-6-oracle $ export JAVA_HOME $ start-all.sh 

If you could show me how to resolve this error it would be greatly appreciated. I'm thinking that my JAVA_HOME is being overridden somehow. If that is the case, could you explain to me how to make my exports global?

like image 633
Ali Ismail Avatar asked Jan 14 '13 19:01

Ali Ismail


People also ask

How do you fix please set the JAVA_HOME variable in your environment to match the location of your Java installation?

To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.

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.

Is it necessary to set JAVA_HOME path?

JAVA_HOME and JRE_HOME are not used by Java itself. Some third-party programs (for example Apache Tomcat) expect one of these environment variables to be set to the installation directory of the JDK or JRE. If you are not using software that requires them, you do not need to set JAVA_HOME and JRE_HOME.


2 Answers

I am using hadoop 1.1, and faced the same problem.

I got it solved through changing JAVA_HOME variable in /etc/hadoop/hadoop-env.sh as:

export JAVA_HOME=/usr/lib/jvm/<jdk folder> 
like image 179
4 revs, 2 users 73% Avatar answered Oct 02 '22 17:10

4 revs, 2 users 73%


The way to solve this problem is to export the JAVA_HOME variable inside the conf/hadoop-env.sh file.

It doesn't matter if you already exported that variable in ~/.bashrc, it'll still show the error.

So edit conf/hadoop-env.sh and uncomment the line "export JAVA_HOME" and add a proper filesystem path to it, i.e. the path to your Java JDK.

# The Java implementation to use. Required.
export JAVA_HOME="/path/to/java/JDK/"

like image 42
Alex Bitek Avatar answered Oct 02 '22 16:10

Alex Bitek