Install Oracle Java JDK Version 8u11 on Fedora

I have tested this method on Fedora 20. It may be similar for the following Linux versions as well

  • Fedora 16 and above
  • CentOS 6 and above
  • Red Hat (RHEL) 6 and above

By default, Openjdk java is provided with the OS. But sometimes, people want to use the Oracle/Sun version.

Difference between Openjdk java and Oracle java

Technical differences are a consequence of the goal of each one (OpenJDK is meant to be the reference implementation, open to the community, while Oracle is meant to be a commercial one)

They both have “almost” the same code of the classes in the Java API; but the code for the virtual machine itself is actually different, and when it comes to libraries, OpenJDK tends to use open libraries while Oracle tends to use closed ones; for instance, the font library.

It is generally preferred to use Oracle Java if you are wishing to develop android apps as some of the features may not work with openjdk java. For general programming openjdk is preferred.

Download the latest rpm file

Method 1

Download Sun/Oracle Java from here
http://www.oracle.com/technetwork/java/javase/downloads/index.html

Select rpm package as follows

  • JDK 32 bit jdk-8u11-linux-i586.rpm
  • JDK 64 bit jdk-8u11-linux-x64.rpm

Method 2

Just type the following in the terminal

## JDK 32-bit ##
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u11-b12/jdk-8u11-linux-i586.rpm"


## JDK 64-bit ##
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u11-b12/jdk-8u11-linux-x64.rpm"

Login as root

Type the following in the terminal

su -

Install Java JDK or JRE package

Double click install the rpm package or just type the following to install the downloaded package.

## JDK 32-bit ##
rpm -Uvh /path/to/binary/jdk-8u11-linux-i586.rpm

## JDK 64-bit ##
rpm -Uvh /path/to/binary/jdk-8u11-linux-x64.rpm

Install browser plugins and javac

Method 1 – Use Java JDK latest version (/usr/java/latest)

Type the following into the terminal

## 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

## javac ##
alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 200000

## jar ##
alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 200000

Method 2 – Use Java JDK absolute version (/usr/java/jdk1.8.0_11)

Type the following in the terminal

## java ##
alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_11/jre/bin/java 200000

## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.8.0_11/jre/bin/javaws 200000

## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk1.8.0_11/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/jdk1.8.0_11/jre/lib/amd64/libnpjp2.so 200000

## javac ##
alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_11/bin/javac 200000

## jar ##
alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_11/bin/jar 200000

Set environmental variable

Setup JAVA_HOME and PATH environment variable, i.e, adding JAVA_HOME environment variable to /etc/profile file or $HOME/.bash_profile file and setting PATH.

Method 1 – Java JDK latest version (/usr/java/latest)

export JAVA_HOME="/usr/java/latest"
export PATH=$PATH:/usr/java/latest/bin:/usr/java/latest/jre/bin

Method 2 – Java JDK absolute version (/usr/java/jdk1.8.0_05)

export JAVA_HOME="/usr/java/jdk1.8.0_11"
export PATH=$PATH:/usr/java/jdk1.8.0_11/bin:/usr/java/jdk1.8.0_11/jre/bin

Checking whether installation is successful

Check java, javaws and javac

checking java

Check mozilla firefox java plugin

Test the plugin out at: www.java.com/en/download/help/testvm.xml
A browser restart is not always required.

You can alse check libjavaplugin.so by restarting Mozilla Firefox and writing about:plugins on address bar.

firefox plugin
I hope this works out for everyone. Comment for any queries and I will reply asap.