Saturday 8 April 2017

How to manually install a new java path to the alternatives java group? How to upgrade Linux java from java version "1.6.0_24" to java version "1.8.0_121"

Step 1 : Check the already installed JAVA in Linux.

Step 2: Command  >>  java -version

[in my case -- java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (rhel-
                     OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode) ]

Step 3: Command  >>  which java

                     [ /usr/bin/java - in all linux its same - its bin file for java ]

Step 4: Command >>   cd /usr/lib/jvm

[ to check libraries of already installed java ]

Step 5: Download new JAVA from oracle

 Use this Link:

Step 6: move this file to     /usr/lib/java/  location {optional}

            command >>     mv jdk-8u121-linux-x64.tar.gz  /usr/lib/java

Step 7: command to extract >>   tar -xvzf jdk-8u121-linux-x64.tar.gz


Step 8: Command >>

  update-alternatives --install "/usr/bin/java" "java" /usr/lib/java/jdk1.8.0_121/bin/java 1


/usr/bin/java -- its bin file for java to install

/usr/lib/java/jdk1.8.0_121/bin/java -- New JDK bin

1 is for priority ]

Step 9: Command >>  update-alternatives --set java /usr/lib/java/jdk1.8.0_121/bin/java


Step 10: check the version   command >>  java -version

Step 11 :  command >>  whereis java

Using alternatives, check if changes have taken effect and finally confirm the java version on system.

Step 12 : command >>   alternatives --config java

[You can also change the selection of java in System]

There are 3 programs which provide 'java'.

Selection    Command
*  1           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
  2           /java/jdk1.8.0_121/bin/java
+ 3            /usr/lib/java/jdk1.8.0_121/bin/java

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


Reference DOC link:

Thanks to all.

No comments:

Post a Comment