• Sales: 1-800-961-2888
  • Support: 1-800-961-4454

How to install the Oracle JDK on Fedora 15 / 16

To run Java applications on Rackspace Cloud Servers you will need a copy of the JRE (Java Runtime Environment) or the JDK (Java Development Kit) installed on your server. Most Linux distributions include an open source version of the JDK, but it can still necessary to install the Oracle version of the JRE or JDK in some cases to satisfy compatibility requirements for some software.

We'll walk you through installing the latest version of the JDK to your system.


First, download a copy of the installation file from the Oracle website, then copy it to your server.  Look for the "linux-x64" rpm for the JDK in the list, with a name like "jdk-7u1-linux-x64.rpm".

Once you have downloaded the JDK installation file you can install it with this command: "sudo rpm -ivh </path/jdk_file.rpm>". For example:

$ sudo rpm -ivh jdk-7u1-linux-x64.rpm
Preparing...                ########################################### [100%]
   1:jdk                    ########################################### [100%]
Unpacking JAR files... 

This will install the JDK to a directory named after the JDK version. At the time of this writing the version is 1.7.0_01, so the directory used is /usr/java/jdk1.7.0_01.

Looking in /usr/java you may notice that there are two symbolic links to /usr/java/jdk1.7.0_01. One is /usr/java/default and the other is /usr/java/latest. The multiple aliases are there because you can have different versions of JDK installed to one system. As the names indicate, you can link the default JDK to any version you prefer while the "latest" is linked to the highest JDK version installed on your system. This is useful and we are going to talk about it in a minute.


The JDK comes with many tools and libraries. To make your Java applications work properly it is essential to set these up properly. Unforunately the installation does not do the configuration for us. We have to manually configure the system.

System environment variables

Use your favourite text editor such as nano or vi to add these two lines to "/etc/environment".


The "latest" here indicates we use the highest version installed on the system. You can change it to "default" or any other version available on your Cloud Server.

Once you've made the change you'll want to have your terminal session re-read the environment variables with the command:

source /etc/environment

Executables, libraries and manual

As many other Linux distros do, Fedora uses "alternatives" to maintain symbolic links to default commands, libraries and man pages. Because the default installation does not create any symbolic links to the system paths you will need to create them manually.

Let's create some directories if they do not already exist by running:

sudo mkdir -p /usr/lib/jvm /usr/lib/jvm-exports

Now you can add JRE and JDK symbolic links to the system in one fell swoop by copying and pasting the following commands into your terminal window. First:

sudo alternatives --install /usr/bin/java java /usr/java/latest/bin/java 15000 \
--slave /usr/lib/jvm/jre jre /usr/java/latest/jre \
--slave /usr/lib/jvm-exports/jre jre_exports /usr/java/latest/jre/lib \
--slave /usr/bin/keytool keytool /usr/java/latest/jre/bin/keytool \
--slave /usr/bin/orbd orbd /usr/java/latest/jre/bin/orbd \
--slave /usr/bin/pack200 pack200 /usr/java/latest/jre/bin/pack200 \
--slave /usr/bin/rmid rmid /usr/java/latest/jre/bin/rmid \
--slave /usr/bin/rmiregistry rmiregistry /usr/java/latest/jre/bin/rmiregistry \
--slave /usr/bin/servertool servertool /usr/java/latest/jre/bin/servertool \
--slave /usr/bin/tnameserv tnameserv /usr/java/latest/jre/bin/tnameserv \
--slave /usr/bin/unpack200 unpack200 /usr/java/latest/jre/bin/unpack200 \
--slave /usr/share/man/man1/java.1 java.1 /usr/java/latest/man/man1/java.1 \
--slave /usr/share/man/man1/keytool.1 keytool.1 /usr/java/latest/man/man1/keytool.1 \
--slave /usr/share/man/man1/orbd.1 orbd.1 /usr/java/latest/man/man1/orbd.1 \
--slave /usr/share/man/man1/pack200.1 pack200.1 /usr/java/latest/man/man1/pack200.1 \
--slave /usr/share/man/man1/rmid.1.gz rmid.1 /usr/java/latest/man/man1/rmid.1 \
--slave /usr/share/man/man1/rmiregistry.1 rmiregistry.1 /usr/java/latest/man/man1/rmiregistry.1 \
--slave /usr/share/man/man1/servertool.1 servertool.1 /usr/java/latest/man/man1/servertool.1 \
--slave /usr/share/man/man1/tnameserv.1 tnameserv.1 /usr/java/latest/man/man1/tnameserv.1 \
--slave /usr/share/man/man1/unpack200.1 unpack200.1 /usr/java/latest/man/man1/unpack200.1

And then:

sudo alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 15000 \
--slave /usr/lib/jvm/java java_sdk /usr/java/latest \
--slave /usr/lib/jvm-exports/java java_sdk_exports /usr/java/latest/lib \
--slave /usr/bin/appletviewer appletviewer /usr/java/latest/bin/appletviewer \
--slave /usr/bin/apt apt /usr/java/latest/bin/apt \
--slave /usr/bin/extcheck extcheck /usr/java/latest/bin/extcheck \
--slave /usr/bin/jar jar /usr/java/latest/bin/jar \
--slave /usr/bin/jarsigner jarsigner /usr/java/latest/bin/jarsigner \
--slave /usr/bin/javadoc javadoc /usr/java/latest/bin/javadoc \
--slave /usr/bin/javah javah /usr/java/latest/bin/javah \
--slave /usr/bin/javap javap /usr/java/latest/bin/javap \
--slave /usr/bin/jconsole jconsole /usr/java/latest/bin/jconsole \
--slave /usr/bin/jdb jdb /usr/java/latest/bin/jdb \
--slave /usr/bin/jhat jhat /usr/java/latest/bin/jhat \
--slave /usr/bin/jinfo jinfo /usr/java/latest/bin/jinfo \
--slave /usr/bin/jmap jmap /usr/java/latest/bin/jmap \
--slave /usr/bin/jps jps /usr/java/latest/bin/jps \
--slave /usr/bin/jrunscript jrunscript /usr/java/latest/bin/jrunscript \
--slave /usr/bin/jsadebugd jsadebugd /usr/java/latest/bin/jsadebugd \
--slave /usr/bin/jstack jstack /usr/java/latest/bin/jstack \
--slave /usr/bin/jstat jstat /usr/java/latest/bin/jstat \
--slave /usr/bin/jstatd jstatd /usr/java/latest/bin/jstatd \
--slave /usr/bin/native2ascii native2ascii /usr/java/latest/bin/native2ascii \
--slave /usr/bin/policytool policytool /usr/java/latest/bin/policytool \
--slave /usr/bin/rmic rmic /usr/java/latest/bin/rmic \
--slave /usr/bin/schemagen schemagen /usr/java/latest/bin/schemagen \
--slave /usr/bin/serialver serialver /usr/java/latest/bin/serialver \
--slave /usr/bin/wsgen wsgen /usr/java/latest/bin/wsgen \
--slave /usr/bin/wsimport wsimport /usr/java/latest/bin/wsimport \
--slave /usr/bin/xjc xjc /usr/java/latest/bin/xjc \
--slave /usr/share/man/man1/appletviewer.1 appletviewer.1 /usr/java/latest/man/man1/appletviewer.1 \
--slave /usr/share/man/man1/apt.1 apt.1 /usr/java/latest/man/man1/apt.1 \
--slave /usr/share/man/man1/extcheck.1 extcheck.1 /usr/java/latest/man/man1/extcheck.1 \
--slave /usr/share/man/man1/jar.1 jar.1 /usr/java/latest/man/man1/jar.1 \
--slave /usr/share/man/man1/jarsigner.1 jarsigner.1 /usr/java/latest/man/man1/jarsigner.1 \
--slave /usr/share/man/man1/javac.1 javac.1 /usr/java/latest/man/man1/javac.1 \
--slave /usr/share/man/man1/javadoc.1 javadoc.1 /usr/java/latest/man/man1/javadoc.1 \
--slave /usr/share/man/man1/javah.1 javah.1 /usr/java/latest/man/man1/javah.1 \
--slave /usr/share/man/man1/javap.1 javap.1 /usr/java/latest/man/man1/javap.1 \
--slave /usr/share/man/man1/jconsole.1 jconsole.1 /usr/java/latest/man/man1/jconsole.1 \
--slave /usr/share/man/man1/jdb.1 jdb.1 /usr/java/latest/man/man1/jdb.1 \
--slave /usr/share/man/man1/jhat.1 jhat.1 /usr/java/latest/man/man1/jhat.1 \
--slave /usr/share/man/man1/jinfo.1 jinfo.1 /usr/java/latest/man/man1/jinfo.1 \
--slave /usr/share/man/man1/jmap.1 jmap.1 /usr/java/latest/man/man1/jmap.1 \
--slave /usr/share/man/man1/jps.1 jps.1 /usr/java/latest/man/man1/jps.1 \
--slave /usr/share/man/man1/jrunscript.1 jrunscript.1 /usr/java/latest/man/man1/jrunscript.1 \
--slave /usr/share/man/man1/jsadebugd.1 jsadebugd.1 /usr/java/latest/man/man1/jsadebugd.1 \
--slave /usr/share/man/man1/jstack.1 jstack.1 /usr/java/latest/man/man1/jstack.1 \
--slave /usr/share/man/man1/jstat.1 jstat.1 /usr/java/latest/man/man1/jstat.1 \
--slave /usr/share/man/man1/jstatd.1 jstatd.1 /usr/java/latest/man/man1/jstatd.1 \
--slave /usr/share/man/man1/native2ascii.1 native2ascii.1 /usr/java/latest/man/man1/native2ascii.1 \
--slave /usr/share/man/man1/policytool.1 policytool.1 /usr/java/latest/man/man1/policytool.1 \
--slave /usr/share/man/man1/rmic.1 rmic.1 /usr/java/latest/man/man1/rmic.1 \
--slave /usr/share/man/man1/schemagen.1 schemagen.1 /usr/java/latest/man/man1/schemagen.1 \
--slave /usr/share/man/man1/serialver.1 serialver.1 /usr/java/latest/man/man1/serialver.1 \
--slave /usr/share/man/man1/wsgen.1 wsgen.1 /usr/java/latest/man/man1/wsgen.1 \
--slave /usr/share/man/man1/wsimport.1 wsimport.1 /usr/java/latest/man/man1/wsimport.1 \
--slave /usr/share/man/man1/xjc.1 xjc.1 /usr/java/latest/man/man1/xjc.1

These two commands look scarily long, but they follow the pattern of link + name + path. Take a close look at each line and compare them and it should be a bit easier to understand what they're doing.

The number 15000 is the priority number for the alternative. You can set it to any integer if you prefer another value. It is only important to change the priority when you have more than one JDK installed.  The system will choose the alternative with the lowest value for its priority if you set it to auto (so "10" has a higher priority than "20", for example).

Checking the install

To make sure the alternatives are set up correctly you can run a couple checks.

First check the "java" command:

alternatives --display java

The output should look similar to this (truncated for length):

java - status is auto. 
 link currently points to /usr/java/latest/bin/java 
/usr/java/latest/bin/java - priority 15000 
 slave jre: /usr/java/latest/jre 
 slave jre_exports: /usr/java/latest/jre/lib 
 slave keytool: /usr/java/latest/jre/bin/keytool 

Next run the test on the "javac" command:

alternatives --display javac

That output should look something like:

javac - status is manual. 
 link currently points to /usr/java/latest/bin/javac                                                                                                         
/usr/java/latest/bin/javac - priority 15000                                                                                                                  
 slave java_sdk: /usr/java/latest                                                                                                                            
 slave java_sdk_exports: /usr/java/latest/lib                                                                                                                
 slave appletviewer: /usr/java/latest/bin/appletviewer                                                                                                       
 slave apt: /usr/java/latest/bin/apt 

Checking the version

To make sure you can execute the "java" command you can run a quick version test:

java -version

The output should be the version of the JDK you have installed.

Switching between installed JDKs

If you need to switch between versions of the JDK (if more than one JDK is installed), run these two commands:

sudo alternatives --config java
sudo alternatives --config javac


That's all done.  You should be able to run "java" (the runtime environment) and "javac" (the compiler) with no problems. We hope you will enjoy the Java experience with Rackspace Cloud Servers.

© 2011-2013 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

See license specifics and DISCLAIMER