Centos – install oracle java using alternatives system on centos 7

centoscentos7java

I installed Oracle's Java onto my 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]$ 

yet, alternatives isn't seeing it:

[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: 

I'm bit confused how to use alternatives --install action, can someone give me a hand please?

Thanks in advance!

Best Answer

I installed java jre using this steps, you can do the same steps for 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