Suvarna Pattayil
Suvarna Pattayil

Reputation: 5239

Error: JAVA_HOME is not set and could not be found. How to set JAVA_HOME permanently in Hadoop?

I installed CDH in Pseudo distributed mode on Ubuntu 12.04.

Prior to it, I installed Java and exported my JAVA_HOME variables to /usr/lib/jvm/java-6-oracle and exported JAVA_HOME to path as well, for both root as well as other users (self, hdfs). and it was echoed correctly as well as showed up in env results.

Still my CDH installation complained of JAVA_HOME not found/set so I added JAVA_HOME to /etc/environment as per this and the entry Defaults env_keep+=JAVA_HOME in /etc/sudoers

All works fine, I can check services are running via Jps, but when I try to stop them as root it says,

service hadoop-hdfs-datanode stop
 * Stopping Hadoop datanode: 
Error: JAVA_HOME is not set and could not be found.

same goes for all other services.

I don't have hadoop-env.sh in my installation, the only one present is at /usr/lib/hadoop-0.20-mapreduce/example-confs/conf.secure/hadoop-env.sh which is an example I believe

Upvotes: 1

Views: 8098

Answers (3)

Vishrant
Vishrant

Reputation: 16698

You should edit etc/hadoop/hadoop-env.sh and add export JAVA_HOME=/usr/java/latest This way your JAVA_HOME will be set permanently

From hadoop documentation

Unpack the downloaded Hadoop distribution. In the distribution, edit the file etc/hadoop/hadoop-env.sh to define some parameters as follows:

set to the root of your Java installation
export JAVA_HOME=/usr/java/latest

Upvotes: 0

Felix Frank
Felix Frank

Reputation: 8223

Cloudera uses BIGTOP to try and detect JAVA_HOME for you. The practice is questionable at best, if you ask me.

You can make this behave correctly by editing a bigtop configuration file. On Debian/Ubuntu, add this to /etc/default/bigtop-utils:

export JAVA_HOME=/correct/path/to/java-home

Upvotes: 3

linux_fanatic
linux_fanatic

Reputation: 5177

Did you try setting the JAVA_HOME in /etc/profile too. Can you please check this link too Hadoop: «ERROR : JAVA_HOME is not set»

Upvotes: 0

Related Questions