(HBase) 错误:未设置 JAVA_HOME 且找不到 Java
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21116916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
(HBase) Error: JAVA_HOME is not set and Java could not be found
提问by Nazanin
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.
我已经阅读了一些关于设置 JAVA_HOME 的评论。由于我是这方面的初学者,因此在不了解我在做什么的情况下没有编辑任何内容。我不想把事情搞得更糟。所以如果你能指导我完成这个并告诉我我的编码有什么问题,我将非常感激。
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.
我一直在尝试先安装 Hadoop,然后再安装 HBase。在经历了很多困难和错误解决之后,我终于可以安装 Hadoop,并在运行时得到这个输出start-all.sh
,一切似乎都很好。
> 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:
我也有这个 Java 版本,当我输入时echo JAVA_HOME
,我得到这个输出:
> 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
在此之后,我尝试安装 HBase(我想我即将放弃),但我不断收到错误消息 JAVA_HOME is not set and java cannot be found
This is what I tried to start Hbase:
这是我尝试启动 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!
我还检查了这个目录/usr/local/hbase/hbase-0.94.6.1/bin
,看看它是否能识别 Java,它确实能!
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.
在搜索了 Strackoverflow 和其他人对同一问题的答案后,我尝试将它们应用于我的 .xml 和 .sh 文件,但再次没有发生任何事情。
For HADOOP
对于 HADOOP
this is the hadoop-env.sh
in which I set the JAVA_HOME:
这是hadoop-env.sh
我在其中设置 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
:
这是编辑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
对于 HBase
These are the edits I have made in hbase-site.xml
这些是我所做的编辑 hbase-site.xml
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:54310 /hbase</value>
</property>
This is for the hbase-env.sh
这是为了 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.
这就是我的猜测。
回答by tobe
Apparently the HBase could not find JAVA_HOME and java binary although you can run java -version
locally.
尽管您可以在java -version
本地运行,但显然 HBase 找不到 JAVA_HOME 和 java 二进制文件。
You should run export JAVA_HOME=/the/path/of/you/jdk/
before running HBase.
您应该export JAVA_HOME=/the/path/of/you/jdk/
在运行 HBase 之前运行。
BTY, echo JAVA_HOME JAVA_HOME
is incorrect. You may want echo $JAVA_HOME
.
BTY,echo JAVA_HOME JAVA_HOME
不正确。你可能想要echo $JAVA_HOME
。
回答by user3093893
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."
“Java需要安装并且可用。如果你得到一个错误,表明Java没有安装,但它在你的系统上,可能在一个非标准的位置,编辑conf/hbase-env.sh文件并修改JAVA_HOME设置指向包含 bin/java 系统的目录。”
The link is http://hbase.apache.org/book/quickstart.html
回答by BenB
You have to set the JAVA home -> you can do this two ways
你必须设置JAVA home -> 你可以通过两种方式做到这一点
Either set the path in hbase-env.sh in ~/hbase-0.98.10-hadoop1/conf JAVA_HOME = 'PATH/TO/JAVE_HOME'
在 ~/hbase-0.98.10-hadoop1/conf JAVA_HOME = 'PATH/TO/JAVE_HOME' 中设置 hbase-env.sh 中的路径
OR in terminal under sudo execute user$ export JAVA_HOME = 'PATH/TO/JAVE_HOME'
或在终端下 sudo 执行 user$ export JAVA_HOME = 'PATH/TO/JAVE_HOME'
Done on OS X (10) hopefully this helps!
在 OS X (10) 上完成希望这会有所帮助!
回答by Amit baderia
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.
如果您已经在 ~/.bashrc 文件中设置了 JAVA_HOME 路径,但 Hbase 仍然给出“找不到 JAVA_HOME”的相同错误,请在 /etc/environment 文件中设置 JAVA_HOME。
I face this issue and it worked for me when i set JAVA_HOME in '/etc/environment'
我遇到了这个问题,当我在“/etc/environment”中设置 JAVA_HOME 时它对我有用
回答by s_jaewoo
Just modify hbase-env.sh
like this:
只需hbase-env.sh
像这样修改:
export JAVA_HOME=/your/java/path
I don't know why /etc/profile
java path doesn't work, but this way would help you.
我不知道为什么/etc/profile
java 路径不起作用,但这种方式会帮助你。
回答by Rakib
Hbase tries to read JAVA_HOME directory set on hbase-env.sh file.
Hbase 尝试读取 hbase-env.sh 文件上设置的 JAVA_HOME 目录。
In hbase-env.sh file
在 hbase-env.sh 文件中
export JAVA_HOME=/usr/java/jdk1.6.0/ is set and commented.
Default JAVA_HOME set for hbase.
为 hbase 设置的默认 JAVA_HOME。
If you set java home in different directory please edit the line and comment out it.
如果您将 java home 设置在不同的目录中,请编辑该行并将其注释掉。
It will solve your problem.
它会解决你的问题。