Centos

在centos 7上使用替代系統安裝oracle java

  • January 9, 2015

我將 Oracle 的 Java 安裝到我的CentOS Linux release 7.0.1406 (Core)

[alexus@wcmisdlin02 Desktop]$ rpm -q jdk1.8.0_25-1.8.0_25-fcs
jdk1.8.0_25-1.8.0_25-fcs.x86_64
[alexus@wcmisdlin02 Desktop]$ 

然而,alternatives沒有看到它:

[alexus@wcmisdlin02 Desktop]$ sudo alternatives --config java

There are 2 programs which provide 'java'.

 Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64/jre/bin/java
  2           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

Enter to keep the current selection[+], or type selection number: 

我有點困惑如何使用alternatives --install動作,有人可以幫我嗎?

提前致謝!

我使用此步驟安裝了 java jre,您可以對 jdk 執行相同的步驟。

tar xvfz jre-8u25-linux-i586.tar.gz
mv jre1.8.0_25/ /opt/
usage: alternatives --install <link> <name> <path> <priority>

alternatives --install /usr/bin/java java /opt/jre1.8.0_25/bin/java 2

alternatives --config java

There are 2 programs which provide 'java'.

 Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
  2           /opt/jre1.8.0_25/bin/java

引用自:https://serverfault.com/questions/658458