(HBase) Error: JAVA_HOME is not set and Java could not be found
Asked Answered
M

6

11

I have read some comments about setting JAVA_HOME. As I am a beginner in this,I did not edit anything without any knowledge of what I was doing. I did not want to mess things up more than this. So if you can guide me through this and tell me what is wrong with my coding, I would really appreciate it.

I have been trying to install Hadoop and then HBase. After a lot of difficulties and error solving, I could finally install Hadoop, and get the this output when I ran start-all.sh and everything seemed to be fine.

> hduser@CSLAP106:~$ /usr/local/hadoop/bin/start-all.sh

> hduser@CSLAP106:~$ jps

> 3005 NameNode

> 3404 JobTracker

> 5570 Jps

> 3554 TaskTracker

> 3311 SecondaryNameNode

I also have this Java Version and when I type echo JAVA_HOME, I get this output:

> hduser@CSLAP106:~$ java -version 
> 
> java version "1.7.0_25" OpenJDK Runtime Environment (IcedTea 2.3.12)
> (7u25-2.3.12-4ubuntu3)   OpenJDK Server VM (build 23.7-b01, mixed
> mode) 
> hduser@CSLAP106:~$ echo JAVA_HOME JAVA_HOME

After this, I tried to install HBase (which I think I am about to give up on), and constantly I get the error that JAVA_HOME is not set and java cannot be found

This is what I tried to start Hbase:

hduser@CSLAP106:~$ /usr/local/hbase/hbase-0.94.6.1/bin/start-hbase.sh
+======================================================================+
|      Error: JAVA_HOME is not set and Java could not be found         |
+----------------------------------------------------------------------+
| Please download the latest Sun JDK from the Sun Java web site        |
|       > http://java.sun.com/javase/downloads/ <                      |
|                                                                      |
| HBase requires Java 1.6 or later.                                    |
| NOTE: This script will find Sun Java whether you install using the   |
|       binary or the RPM based installer.                             |
+======================================================================+

I also check in this directory /usr/local/hbase/hbase-0.94.6.1/bin to see if it recognizes Java or not, and it does!

After searching through Strackoverflow and other people's answers to the same problem, I tried to apply them to my .xml and .sh files, but again nothing happened.

For HADOOP

this is the hadoop-env.sh in which I set the JAVA_HOME:

# The java implementation to use.  Required.
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386

This is the editing for my $HOME/.bashrc :

# Set Hadoop-related environment variables
export HADOOP_HOME=/usr/local/hadoop

export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386

# Add Hadoop bin/ directory to PATH

export PATH=$PATH:$HADOOP_HOME/bin

For HBase

These are the edits I have made in hbase-site.xml

<property>
        <name>hbase.rootdir</name>
    <value>hdfs://localhost:54310 /hbase</value>
</property>

This is for the hbase-env.sh

# The java implementation to use.  Java 1.6 required.
# export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386

This is all I guess.

Mathew answered 14/1, 2014 at 15:10 Comment(14)
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386 in hbase-env.sh is outcommented?Hydatid
@DavidEverlöf: By out-commented, what do you mean? I think the first time I read your comment, I got it wrong. I thought you meant I should have added ' # ' to that comment, and when I did it, I started to receive error! So I guess you meant something esle by 'outcommented' that I did not quite get!Mathew
I meant that the row that is # export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386 should not have an startint # and be export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386 instead!Hydatid
@DavidEverlöf: THANK YOU VERY MUCH DAVID! That solved my problem. HBase just launched, however, it did not give me the H Master I was looking for when I typed JPS. It shows starting master, logging to /usr/local/hbase/hbase-0.94.6.1/bin/../logs/hbase-hduser-master-CSLAP106.out /usr/local/hbase/hbase-0.94.6.1/bin/hbase-daemon.sh: line 150: /usr/local/hbase/hbase-0.94.6.1/bin/../logs/hbase-hduser-master-CSLAP106.log: No such file or directoryMathew
Are you sure you're running the script as root?Hydatid
@DavidEverlöf: I run the script with the hduser and when I want to execute the sh file, it gives me a permission denied error . I will copy the error I get: starting master, logging to /usr/local/hbase/hbase-0.94.6.1/bin/../logs/hbase-hduser-master-CSLAP106.out- /usr/local/hbase/hbase-0.94.6.1/bin/hbase-daemon.sh: line 150: /usr/local/hbase/hbase-0.94.6.1/bin/../logs/hbase-hduser-master-CSLAP106.log: Permission denied- head: cannot open ‘/usr/local/hbase/hbase-0.94.6.1/bin/../logs/hbase-hduser-master-CSLAP106.out’ for reading: No such file or directoryMathew
Try running the script with sudo sh ./script.sh!Hydatid
@DavidEverlöf: It says: The authenticity of host 'localhost (127.0.0.1)' can't be established - Are you sure you want to continue connecting (yes/no)? yes It requires the localhost password. what is the password for it? (Sorry if my questions are stupid, I'm new in this completely. I really appreciate your help.)Mathew
Not really sure, did you try leaving it empty? Or maybe try "admin" or "localhost"Hydatid
@DavidEverlöf: I tried admin, localhost, and left it empty. It did not work. root@localhost's password: - localhost: Permission denied, please try again. - localhost: Permission denied (publickey,password). - starting master, logging to /usr/local/hbase/hbase-0.94.6.1/bin/../logs/hbase-root-master-CSLAP106.out - But it does not log in to master, and again asks for a passwordMathew
Is it your computer? Or what computer is it you're logged in on?Hydatid
@DavidEverlöf: It is my work place computer, but the admin is set to be meMathew
Guess I really cant help you anymore.. Isnt there anyone at your workplace that can help you with this?Hydatid
@DavidEverlöf: Unfortunately, nope :( ... But thank you soooo very much for you help and patience. :) Maybe I can ask this as a new thread in the forum.Mathew
L
4

Apparently the HBase could not find JAVA_HOME and java binary although you can run java -version locally.

You should run export JAVA_HOME=/the/path/of/you/jdk/ before running HBase.

BTY, echo JAVA_HOME JAVA_HOME is incorrect. You may want echo $JAVA_HOME.

Leiker answered 1/9, 2014 at 2:25 Comment(0)
E
4

Hbase tries to read JAVA_HOME directory set on hbase-env.sh file.

In hbase-env.sh file

export JAVA_HOME=/usr/java/jdk1.6.0/ is set and commented.

Default JAVA_HOME set for hbase.

If you set java home in different directory please edit the line and comment out it.

It will solve your problem.

Explanation answered 26/8, 2017 at 6:8 Comment(0)
D
1

Please refer to below:

"Java needs to be installed and available. If you get an error indicating that Java is not installed, but it is on your system, perhaps in a non-standard location, edit the conf/hbase-env.sh file and modify the JAVA_HOME setting to point to the directory that contains bin/java your system."

The link is http://hbase.apache.org/book/quickstart.html

Detrude answered 11/12, 2014 at 7:40 Comment(0)
R
1

If you have already set JAVA_HOME path in ~/.bashrc file and still Hbase is giving the same error of "JAVA_HOME not found", set JAVA_HOME in /etc/environment file.

I face this issue and it worked for me when i set JAVA_HOME in '/etc/environment'

Rickard answered 8/10, 2015 at 17:20 Comment(0)
P
1

Just modify hbase-env.sh like this:

export JAVA_HOME=/your/java/path

I don't know why /etc/profile java path doesn't work, but this way would help you.

Plutocracy answered 26/12, 2016 at 8:0 Comment(0)
S
0

You have to set the JAVA home -> you can do this two ways

Either set the path in hbase-env.sh in ~/hbase-0.98.10-hadoop1/conf JAVA_HOME = 'PATH/TO/JAVE_HOME'

OR in terminal under sudo execute user$ export JAVA_HOME = 'PATH/TO/JAVE_HOME'

Done on OS X (10) hopefully this helps!

Sabulous answered 9/2, 2015 at 0:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.