Junk Food for the Brain

Open Source and Awesomesauce :)

Fedora 16 Use Sun Java JDK

| Comments

Fedora 16 comes with OpenJDK by default. For certain application, you are required to use the SUN JDK. This post shows you how to download and install the latest Oracle Java Development Kit (JDK) and set Fedora to use it by default.

Download the latest Java JDK from here.

http://www.oracle.com/technetwork/java/javase/overview/index.html

I used the tar.gz version. I choose to install it in /opt

tar -zxf /path/to/your/jdk/download/jdk-7u2-linux-x64.tar.gz -C /opt

This extracts the Java JDK to /opt/jdk1.7.0_02

Use the alternatives command to then set this as the default java.

# /usr/sbin/alternatives --install /usr/bin/java java /opt/jdk1.7.0_02/bin/java 200

Where:

  • –install - Command to add an ‘alternative’
  • /usr/bin/java - where the java program should be linked to
  • java - The type of ‘alternative’ we are installing
  • /opt/jdk1.7.0_02/bin/java - The full path to the java binary
  • 200 - The priority of this version, the higher the number, the higher the chance of it being used first

Test this in the command line by typing

$ java -version
java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)

You will now see that it uses the Oracle Java.