Java on Linux: How to install and enable Oracle’s Java instead of OpenJDK

Many of the major Linux distributions come bundled with OpenJDK Java instead of the “standard” Sun Java or — since Sun Microsystems acquisition by Oracle in 2010 — Oracle Java. One such distro is Fedora, for example.

Open JDK is ok in most cases but there are situations where you need to install the “real” Java on your computer and/or be able switch between them.

This article : http://www.if-not-true-then-false.com/2014/install-oracle-java-8-on-fedora-centos-rhel – is the best info on the subject I have seen so far.

Key points to remember:
——————————-
1. After installing the new Java package run ‘alternatives’ to make the system recognizes that this is the Java environment from now on:

## java ##
$ alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 200000

## javaws ##
$ alternatives --install /usr/bin/javaws javaws \
/usr/java/latest/jre/bin/javaws 200000

## Java Browser (Mozilla) Plugin 32-bit ##
$ alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so \
libjavaplugin.so /usr/java/latest/jre/lib/i386/libnpjp2.so 200000

## Java Browser (Mozilla) Plugin 64-bit ##
$ alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so \
libjavaplugin.so.x86_64 /usr/java/latest/jre/lib/amd64/libnpjp2.so 200000

## Install javac only if you installed JDK (Java Development Kit) package ##
$ alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 200000
$ alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 200000
 

2. Check Java and the Java plug-in versions to ensure that they were changed as expected ($ java -version and about:plugins).

3. You can use  alternatives --config   if you ever want to go back to one of the previous versions:

$ alternatives --config java

There are 7 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           /usr/java/jre1.8.0_51/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
   3           /usr/java/jre1.8.0_45/bin/java
   4           /usr/java/jdk1.8.0_91/jre/bin/java
   5           /usr/java/jre1.8.0_91/bin/java
*+ 6           /usr/java/latest/bin/java
   7           /usr/java/latest/jre/bin/java

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

4. Older Java releases can be downloaded from: http://www.oracle.com/technetwork/java/javase/archive-139210.html

Leave a Reply

Your email address will not be published. Required fields are marked *