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 : – 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/ \ /usr/java/latest/jre/lib/i386/ 200000

## Java Browser (Mozilla) Plugin 64-bit ##
$ alternatives --install /usr/lib64/mozilla/plugins/ \ /usr/java/latest/jre/lib/amd64/ 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:

Leave a Reply

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