View Full Version : Setting up Oracle JDK

5th April 2013, 07:29 AM
Might be a better way, but this works well for me. Please share if there is, I tried to find something fedora specific before adapting an Ubuntu guide I found.

Java can be a bit complex to install and get working. One of the issues is that Fedora already ships with an open-source Java implementation called OpenJDK. It has an open source plugin called icedtea. If they were truly compatible with all the Java stuff out there, we wouldn't have to worry. Unfortunately there are parts of Sun/Oracle Java that are not (yet) implemented in the OpenJDK and unfortunately I need them on a web site I visit.

The application could probably be fixed to work with IcedTea but I have no idea how easy that would be.

These instructions were adapted for Fedora from:

First download the JDK. It can be found at:

What you want is the Java Platform - don't worry about JavaFX or NetBeans unless you know you need them.
Clicking on the Java Platform option brings you to the download page. You'll have to check the radio box indication you accept the license agreement (feel free to read it first) then select the download. For Linux there are four options. Two of them are for 64-bit Linux, an RPM and a tarball (tar.gz). Get the tarball.

The open source community has offered well written RPM spec files first to Sun and then Oracle for well over a decade and they seem to ignore us, instead releasing RPM files that do not take advantage of what RPM offers and their RPMs have been known to sometimes cause issues in the past. So I avoid them, and use the tarball. It's a decent sized download, ~ 90MB.

At the time of this writing, the current file name that you will download is jdk-7u17-linux-x64.tar.gz

Once the download is complete, open a terminal and become the root user.

First, I recommend getting rid of OpenJDK. This may not be absolutely necessary, I would think alternatives should allow both, but...
You will at least want to un-install the icedtea plugin (icedtea-web).

yum remove java-1.7.0-openjdk

That will remove some packages that require Java, such as eclipse if you have it installed (eclipse is an IDE for developing Java applications, it can also be used for developing Android applications)

If you need eclipse, you can install it again later, though not from Fedora as Fedora packaging will want to re-install OpenJDK - you'll have to get it from http://www.eclipse.org/ - it will work just fine with the Oracle JDK.

Now we will install the Oracle JDK:

mkdir /usr/local/java
cd /usr/local/java
tar -zxf /home/[your normal username]/Downloads/jdk-7u17-linux-x64.tar.gz

Those commands will create the install location and unpack the tarball. Now we have to make sure the Oracle Java executables will be easily available to users and applications. This is done by creating a small file in the /etc/profile.d directory:

cat <<EOF > /etc/profile.d/oracleJava.sh
export JAVA_HOME=/usr/local/java/jdk1.7.0_17
export PATH=${PATH}:${JAVA_HOME}/bin

Copy that exactly as it is there. Next, the alternatives is system is a system that allows different implementations of software to be installed. Fedora (and most distributions) use the alternatives system for Java. We need to let the alternatives system know about the freshly installed Java:

update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.7.0_17/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0_17/bin/javac" 1
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.7.0_17/bin/javaws" 1

Next, we need to tell the alternatives system to use the freshly installed Java as default:

update-alternatives --set java /usr/local/java/jdk1.7.0_17/bin/java
update-alternatives --set javac /usr/local/java/jdk1.7.0_17/bin/javac
update-alternatives --set javaws /usr/local/java/jdk1.7.0_17/bin/javaws

Finally we can set up the plugin for use:

pushd /usr/lib64/mozilla/plugins
ln -s /usr/local/java/jdk1.7.0_17/jre/lib/amd64/libnpjp2.so .

If you have an Intel processor, don't worry about the amd64 - current 64-bit Intel uses amd64 instruction set.
At this point you should log out and log back in, and the Java plugin should be working.

Congratulations, you have now defiled your system ;)

When there is a know security vulnerability announced, just go to the /usr/lib64/mozilla/plugins directory and delete the symlink and wait for Oracle to release an update. When they do, follow these instructions again with the new updated version.

You can always check to see if you are current at http://www.java.com/en/download/testjava.jsp