Charul
Charul

Reputation: 450

HBase giving "JAVA_HOME is not set" while running

I am using MacOS Sierra version 10.12.4 and using zsh shell. I have installed HBase version 1.2.6 and trying to run it. I have pre-installed JAVA JDK version 1.8.0_131.

I have set up the $JAVA_HOME path in ~.bash_profile and ~.zshrc and also in hbase-1.2.6/conf/hbase-env.sh file. So when I run the following commands, it shows this

 ❯ echo $JAVA_HOME                                                                                                                                                        

 /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/

❯ $JAVA_HOME/bin/java -version                                                                                                                                           [16:55:16]
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

But, when I run the following commands inside the folder hbase-1.2.6 to run the HBase, it gives me JAVA_HOME is not set error.

 ❯ sudo bin/start-hbase.sh                                                                                                                                            

Password:
+======================================================================+
|                    Error: JAVA_HOME is not set                       |
+----------------------------------------------------------------------+
| Please download the latest Sun JDK from the Sun Java web site        |
|     > http://www.oracle.com/technetwork/java/javase/downloads        |
|                                                                      |
| HBase requires Java 1.7 or later.                                    |
+======================================================================+


❯ sudo bin/hbase shell                                                                                                                                                   [16:58:36]
+======================================================================+
|                    Error: JAVA_HOME is not set                       |
+----------------------------------------------------------------------+
| Please download the latest Sun JDK from the Sun Java web site        |
|     > http://www.oracle.com/technetwork/java/javase/downloads        |
|                                                                      |
| HBase requires Java 1.7 or later.                                    |
+======================================================================+                           |

I am able to run it at the user level without using sudo. How can I run at the sudo level?

Upvotes: 3

Views: 1357

Answers (2)

Rakib
Rakib

Reputation: 2086

Step 1: Search JAVA_HOME in  hbase-env.sh 
Step 2: Comment out # from JAVA_HOME line and edit the JAVA_HOME directory

Upvotes: 1

Hasnain Ali Bohra
Hasnain Ali Bohra

Reputation: 2180

You should run

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jd‌​k/Contents/Home/ 

before running HBase inside the HBase diretory. And also check that JAVA_HOME is pointing to correct directory in Linux.

Upvotes: 0

Related Questions