0

I am pretty novice when it comes to Ubuntu but I am trying to follow along with the install instructions for Cloudera located here.

At step 1, I am getting to following error:

brock@brock-hpserver:~$ sudo -u hdfs hdfs namenode -format
Error: JAVA_HOME is not set and could not be found.

However, although I could be wrong, I believe I have everything set up properly:

brock@brock-hpserver:~$ echo $JAVA_HOME
/usr/lib/jvm/java-6-openjdk-amd64
brock@brock-hpserver:~$ echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:JAVA_HOME/bin

And finally my java version:

brock@brock-hpserver:~$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-0ubuntu1~12.04.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

Any help will be greatly appreciated. I simply just want to poke around and learn Hadoop on a spare machine at home.

Btibert3
  • 38,798
  • 44
  • 129
  • 168

2 Answers2

3

I met the same problem, just add JAVA_HOME="directory_to_JDK" setting into the /etc/environment, and it works.

pb2q
  • 58,613
  • 19
  • 146
  • 147
chenrui
  • 8,910
  • 3
  • 33
  • 43
2

The JAVA_HOME is defined for your process, but not for the process in which the sudo is running. export the JAVA_HOME definition. I don't recall the syntax, but I believe it's similar to export JAVA_HOME=/drive/dir1/dir2/java

If that does not work, JAVA_HOME can be defined at the system level, for all processes. It's been a long time, I don't recall how. But hopefully there's enough here to allow you to Google.

Here's a SO link about export.

Community
  • 1
  • 1
Tony Ennis
  • 12,000
  • 7
  • 52
  • 73