“哪个java”在CentOS中打印错误的Java路径 [英] "which java" in CentOS prints wrong java path
问题描述
我不确定为什么 哪个java 和 其中Java 路径不正确。我尝试编辑〜/ .bash_profile和/ etc / environment,但没有帮助。所需的路径是在下面的 echo $ JAVA_HOME 中看到的路径,但在 哪个java 中没有反映出相同的路径
I am not sure why "which java" and "whereis java" paths are not correct. I tried to edit ~/.bash_profile and /etc/environment but did not help. The desired path is what is seen in "echo $JAVA_HOME" below but the same is not reflected in "which java"
以下是我在CentOS 6.4中获得的内容:
Below is what I get in CentOS 6.4:
其中的Java
which java
/ usr / bin / java
/usr/bin/java
java -version
java -version
java版本 1.7.0_45
java version "1.7.0_45"
JAVA(TM)SE运行时环境(内部版本1.7.0_45-b18)
JAVA(TM) SE Runtime Environment (build 1.7.0_45-b18)
JAVA HotSpot(TM)64位服务器VM(内部版本24.45-b08,混合模式) )
JAVA HotSpot (TM) 64-bit Server VM (build 24.45-b08, mixed mode)
whereis java
whereis java
java:/ usr / bin / java / etc / java / usr / lib / java / usr / share / java
java: /usr/bin/java /etc/java /usr/lib/java /usr/share/java
回显$ JAVA_HOME
/usr/java/jdk1.7.0_45/jre =>何时显示正确echo $ JAVA_HOME
/usr/java/jdk1.7.0_45/jre => desired shows correct when echo $JAVA_HOME
推荐答案
运行 alternatives --config java
选择Java版本y您想使用默认值。它将打印出已安装的Java列表供您选择。
Run alternatives --config java
to pick the Java version you want to use as default. It will print out a list of installed Javas to choose from.
其中Java
始终会打印出来 / usr / bin / java
。这并不意味着设置有误!观察:
which java
, however, will always print out /usr/bin/java
. This doesn't mean it's set wrong! Observe:
$ ls -l `which java`
lrwxrwxrwx 1 root root 22 Oct 19 11:49 /usr/bin/java -> /etc/alternatives/java
$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 35 Oct 19 11:49 /etc/alternatives/java -> /usr/lib/jvm/jre-1.5.0-gcj/bin/java
如果使用 alternatives
更改到IcedTea的路径, ls -l / etc / alternatives / java
会反映出来。
If you use alternatives
to change the path to IcedTea, ls -l /etc/alternatives/java
will reflect that.
这篇关于“哪个java”在CentOS中打印错误的Java路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!