3

I am installing Hadoop on CentOS 6.4.
Following these instructions http://hadoop.apache.org/docs/stable/single_node_setup.html

wget http://apache.osuosl.org/hadoop/common/hadoop-1.1.2/hadoop-1.1.2-1.x86_64.rpm
chmod 700 hadoop-1.1.2-1.x86_64.rpm
rpm -Uvh hadoop-1.1.2-1.x86_64.rpm

Java is located at /usr/bin/java

[root@localhost ~]# /usr/bin/java -version
java version "1.7.0_09-icedtea"
OpenJDK Runtime Environment (rhel-2.3.4.1.el6_3-x86_64)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)

set JAVA_HOME

vi /etc/hadoop/hadoop-env.sh 

changed
export JAVA_HOME=/usr/bin/java/bin/java
to
export JAVA_HOME=/usr/bin/java

[root@localhost ~]# . /etc/hadoop/hadoop-env.sh
[root@localhost ~]# echo $JAVA_HOME
/usr/bin/java

But Hadoop still fails as it has the old incorrect Java path

[root@localhost ~]# /usr/bin/hadoop version
/usr/bin/hadoop: line 320: /usr/bin/java/bin/java: Not a directory

How do I correct this error message?

davidjhp
  • 630
  • 2
  • 7
  • 13

3 Answers3

5

JAVA HOME need to be set just to /usr so that adding bin/java will get you to the right place.

# export JAVA_HOME="/usr"
# /usr/bin/hadoop version
slm
  • 7,355
  • 16
  • 54
  • 72
przRocco
  • 396
  • 1
  • 4
1

JAVA_HOME must always point to the home directory of the java installation, setting to /usr is not recommended in practice. Also, If any of other Applications installed on you box may rely on the JAVA_HOME and it would expect it to point to /usr/java/jdk1.7 (fox ex).

export JAVA_HOME=/usr/java/jdk1.7 (You could do this in /etc/hadoop/hadoop-env.sh).

Also, Adding the path of the hadoop Binaries location (for. ex. /usr/local/hadoop/bin) to $PATH would let you to just type the command instead of the full path of the command.

datarockz2
  • 176
  • 1
  • 3
1

As mentioned, problem is solved by setting the real Java location instead of a link to it, to find it:

(Replace the path of 2,3 with the result of the previous one)

$ which java
$ ls -alh /usr/bin/java
$ ls -alh /etc/alternatives/java

Now you can set that in your .bashrc or .profile or wherever you need it.

export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export PATH=$PATH:$JAVA_HOME
Itzco
  • 11
  • 1