JAVA不在路径中,尽管是JAVA_HOME设置

时间:2021-12-01 11:08:42

I have set all the requirement variables in the /etc/profile but when launching elasticsearch, it is still not find Java. How i can set the environment variable. That's my /etc/profile

我已经在/etc/profile中设置了所有的需求变量,但是在启动elasticsearch时,仍然没有找到Java。如何设置环境变量。这是我的/ etc / profile

PATH=$PATH:$HOME/bin
APPLICATIONS=$HOME/Applications
JAVA_HOME=$APPLICATIONS/jdk1.7.0_79
PATH=$JAVA_HOME/bin:$PATH

export APPLICATIONS
export JAVA_HOME
export PATH

Output of commands

命令的输出

[root@87500e63467f Applications]# echo $PATH
/root/Applications/jdk1.7.0_79/bin:/root/Applications/jdk1.7.0_79/bin:/root/Applications/jdk1.7.0_79/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin:/root/bin
[root@87500e63467f Applications]# echo $JAVA_HOME
/root/Applications/jdk1.7.0_79
[root@87500e63467f Applications]# java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
error: "Read-only file system" setting key "vm.max_map_count"
Starting elasticsearch: which: no java in (/sbin:/usr/sbin:/bin:/usr/bin)
Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME
                                                           [FAILED]

in the error, it says that ""Starting elasticsearch: which: no java in (/sbin:/usr/sbin:/bin:/usr/bin)"", it means really java isn't in that path, but how come when I echo $PATH, it shows that the java is in the path ?

在错误中,它说“启动弹搜索:which: no java in (/sbin:/usr/sbin:/bin:/usr/bin:/usr/bin)”这意味着真正的java不在这条路上,但是当我返回$ path时,它显示java在路径中?

9 个解决方案

#1


1  

Specifically for OpenBSD6.0, add

专门为OpenBSD6.0,添加

export JAVA_HOME=/usr/local/jdk-1.8.0/

to your .profile.

你的. profile。

This specific version of the jdk, and possibly the basic path itself is subject to change in subsequent and previous versions of OpenBSD, you have been warned.

这个特定版本的jdk,以及可能的基本路径本身在OpenBSD的后续和以前的版本中可能会发生更改,您已经得到了警告。

#2


24  

After reading the docs from ElasticSearch, I found that if you're running on Ubuntu or Debian, the package only ships with the OpenJDK because of licensing issues. To fix this Java path problem, I installed the following after installing ElasticSearch (as directed by the docs):

在阅读了ElasticSearch提供的文档后,我发现如果你在Ubuntu或Debian上运行,由于许可问题,这个包只能附带OpenJDK。为了解决这个Java路径问题,我在安装了ElasticSearch(按照文档的指示)之后安装了以下软件:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
java -version

Then upon running sudo service elasticsearch start everything worked and I had no more Java path issues.

然后运行sudo服务的弹性搜索开始一切工作,我没有更多的Java路径问题。

#3


8  

run the command

运行以下命令

java -XshowSettings

search the entry java.home = /usr/java/jdk1.8.0_91/jre

java搜索条目。家= /usr/java/jdk1.8.0_91 / jre

export the java_home in your bash profile

在bash配置文件中导出java_home。

export JAVA_HOME=/usr/java/jdk1.8.0_91/jre

or in /etc/profile to expand to all users

或者在/etc/profile中向所有用户扩展。

#4


1  

To get it going - though not nice - you could setup a symbolic link to your java in /usr/bin (which is listed by elasticsearch to be seen):

为了让它运行——尽管不是很好——你可以在/usr/bin中设置一个符号链接到你的java(它是由弹性搜索列出的):

ln -s /root/Applications/jdk1.7.0_79/bin/java /usr/bin/java

#5


1  

I noticed one file in the output called /etc/sysconfig/elasticsearch

我注意到输出中有一个文件叫做/etc/sysconfig/elasticsearch

this might do the trick, so I defined JAVA_HOME in this file like, and it works.

这可能会达到目的,所以我在这个文件中定义了JAVA_HOME,它是有效的。

more u can get from here

从这里你可以得到更多

#6


0  

Make sure the path you have provided for JAVA_HOME is correct.

确保为JAVA_HOME提供的路径是正确的。

And why not keep it simple:

为什么不简单点:

export PATH=$PATH:/path/to/jdk

try to set Java home to /jdk1.7.0_79/bin and see if that helps.

尝试将Java home设置为/jdk1.7.0_79/bin,看看这是否有帮助。

#7


0  

Simply add the below path in bashrc and profile file under /etc/ directory.

只需在bashrc中添加以下路径,并在/etc/目录下添加概要文件。

export JAVA_HOME=/path/to/java/jdk

出口JAVA_HOME = /道路/ / java / jdk

export PATH=$JAVA_HOME/bin:$PATH

导出路径= $ JAVA_HOME / bin:$路径

#8


0  

Encountered the same issue while installing Elasticsearch 5 on a debian machine. That's how I installed Java 9:

在debian机器上安装Elasticsearch 5时遇到了同样的问题。我就是这样安装Java 9的:

su -
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java9-installer

#9


0  

I don't know if this is your particular situation, but working with ElasticSearch/Kibana/Logstash (ELK stack) the docs didn't work for me on Ubuntu 16.04. Putting content from this post together with several others, my solution was:

我不知道这是不是你的特殊情况,但是在使用ElasticSearch/Kibana/ loghide (ELK stack)时,文档对我在Ubuntu 16.04上并不适用。将这篇文章的内容与其他几篇文章放在一起,我的解决方案是:

 sudo add-apt-repository ppa:webupd8team/java
 sudo apt-get update
 sudo apt-get install oracle-java8-installer
 # checking my work given 9 won't work with OSSEC you can use
 # java -version
 sudo usermod -a -G ossec logstash
 sudo apt-get install logstash
 sudo systemctl daemon-reload
 sudo systemctl enable logstash.service
 sudo systemctl start logstash.service

The end result for me on ubuntu 16.04 was

ubuntu 16.04的最终结果是

sudo java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

If you are working with wazuh, it is important to add the PPAs for their specific versions. I hope this helps.

如果您正在与wazuh合作,那么在其特定版本中添加PPAs非常重要。我希望这可以帮助。

#1


1  

Specifically for OpenBSD6.0, add

专门为OpenBSD6.0,添加

export JAVA_HOME=/usr/local/jdk-1.8.0/

to your .profile.

你的. profile。

This specific version of the jdk, and possibly the basic path itself is subject to change in subsequent and previous versions of OpenBSD, you have been warned.

这个特定版本的jdk,以及可能的基本路径本身在OpenBSD的后续和以前的版本中可能会发生更改,您已经得到了警告。

#2


24  

After reading the docs from ElasticSearch, I found that if you're running on Ubuntu or Debian, the package only ships with the OpenJDK because of licensing issues. To fix this Java path problem, I installed the following after installing ElasticSearch (as directed by the docs):

在阅读了ElasticSearch提供的文档后,我发现如果你在Ubuntu或Debian上运行,由于许可问题,这个包只能附带OpenJDK。为了解决这个Java路径问题,我在安装了ElasticSearch(按照文档的指示)之后安装了以下软件:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
java -version

Then upon running sudo service elasticsearch start everything worked and I had no more Java path issues.

然后运行sudo服务的弹性搜索开始一切工作,我没有更多的Java路径问题。

#3


8  

run the command

运行以下命令

java -XshowSettings

search the entry java.home = /usr/java/jdk1.8.0_91/jre

java搜索条目。家= /usr/java/jdk1.8.0_91 / jre

export the java_home in your bash profile

在bash配置文件中导出java_home。

export JAVA_HOME=/usr/java/jdk1.8.0_91/jre

or in /etc/profile to expand to all users

或者在/etc/profile中向所有用户扩展。

#4


1  

To get it going - though not nice - you could setup a symbolic link to your java in /usr/bin (which is listed by elasticsearch to be seen):

为了让它运行——尽管不是很好——你可以在/usr/bin中设置一个符号链接到你的java(它是由弹性搜索列出的):

ln -s /root/Applications/jdk1.7.0_79/bin/java /usr/bin/java

#5


1  

I noticed one file in the output called /etc/sysconfig/elasticsearch

我注意到输出中有一个文件叫做/etc/sysconfig/elasticsearch

this might do the trick, so I defined JAVA_HOME in this file like, and it works.

这可能会达到目的,所以我在这个文件中定义了JAVA_HOME,它是有效的。

more u can get from here

从这里你可以得到更多

#6


0  

Make sure the path you have provided for JAVA_HOME is correct.

确保为JAVA_HOME提供的路径是正确的。

And why not keep it simple:

为什么不简单点:

export PATH=$PATH:/path/to/jdk

try to set Java home to /jdk1.7.0_79/bin and see if that helps.

尝试将Java home设置为/jdk1.7.0_79/bin,看看这是否有帮助。

#7


0  

Simply add the below path in bashrc and profile file under /etc/ directory.

只需在bashrc中添加以下路径,并在/etc/目录下添加概要文件。

export JAVA_HOME=/path/to/java/jdk

出口JAVA_HOME = /道路/ / java / jdk

export PATH=$JAVA_HOME/bin:$PATH

导出路径= $ JAVA_HOME / bin:$路径

#8


0  

Encountered the same issue while installing Elasticsearch 5 on a debian machine. That's how I installed Java 9:

在debian机器上安装Elasticsearch 5时遇到了同样的问题。我就是这样安装Java 9的:

su -
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java9-installer

#9


0  

I don't know if this is your particular situation, but working with ElasticSearch/Kibana/Logstash (ELK stack) the docs didn't work for me on Ubuntu 16.04. Putting content from this post together with several others, my solution was:

我不知道这是不是你的特殊情况,但是在使用ElasticSearch/Kibana/ loghide (ELK stack)时,文档对我在Ubuntu 16.04上并不适用。将这篇文章的内容与其他几篇文章放在一起,我的解决方案是:

 sudo add-apt-repository ppa:webupd8team/java
 sudo apt-get update
 sudo apt-get install oracle-java8-installer
 # checking my work given 9 won't work with OSSEC you can use
 # java -version
 sudo usermod -a -G ossec logstash
 sudo apt-get install logstash
 sudo systemctl daemon-reload
 sudo systemctl enable logstash.service
 sudo systemctl start logstash.service

The end result for me on ubuntu 16.04 was

ubuntu 16.04的最终结果是

sudo java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

If you are working with wazuh, it is important to add the PPAs for their specific versions. I hope this helps.

如果您正在与wazuh合作,那么在其特定版本中添加PPAs非常重要。我希望这可以帮助。