Java – Error: JAVA_HOME is not set and could not be found. How do I set up JAVA_HOME permanently in Hadoop?

Error: JAVA_HOME is not set and could not be found. How do I set up JAVA_HOME permanently in Hadoop?… here is a solution to the problem.

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

I installed CDH in Pseudo distributed mode is on Ubuntu 12.04.

Before that, I installed Java and exported my JAVA_HOME variables to /usr/lib/jvm/java-6-oracle and exported JAVA_HOME to path, for root and other users (myself, hdfs). It is echoed correctly and displayed in the env result.

My CDH install still says JAVA_HOME not found/set so I follow this add JAVA_HOME to /etc/ environment and the entry Defaults env_keep+=JAVA_HOME in /etc/sudoers

Everything works fine, I can check if the services are running through 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.

The same goes for all other services.

I don’t have hadoop-env.sh in my installation, the only thing that exists is /usr/lib/hadoop-0.20-mapreduce/example-confs/conf. secure/hadoop-env.sh I believe this is an example

Solution

Cloudera uses BIGTOP Try to detect the JAVA_HOME for you. If you ask me, this practice is problematic at best.

You can make it work properly by editing the bigtop configuration file. On Debian/Ubuntu, add this to /etc/default/bigtop-utils:

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

Related Problems and Solutions