Personal tools
You are here: Home Team Members Jason Farrell Using Sun Java instead of OpenJDK

Using Sun Java instead of OpenJDK

by zcat last modified Sep 07, 2011 02:15 PM

How to download, install, and switch to Sun's Java. Covers the JRE (browser plugin, java runtime, utils), and the JDK (JRE + dev tools); 32-bit and 64-bit.

Applicable to Fedora Versions

  • Fedora 12+

Doing the Work

If, for whatever reason, OpenJDK isn't working 100% for you, then here's how to use Sun Java instead:

  1. Download the latest update of the Sun Java JRE or JDK by clicking the "Download JRE" button (for users) or the "Download JDK" button (for developers) from the "Java Platform, Standard Edition" section located here:

    Accept the license agreement and download either the "Linux x86 - RPM Installer" if running 32-bit Fedora, or the "Linux x64 - RPM Installer" if 64-bit.

    IMPORTANT: When downloading Java 7, download the .rpm version, and not the ".tar.gz" version (unless you know what you're doing). If downloading the older Java 6 release, make sure to get the "*-rpm.bin" (RPM) option; NOT the self-extracting installer version with only ".bin" in the filename. e.g.:
      Java 7 downloads
    • JRE 7 (for users who only require the plugin, and the java runtime):
      • jre-7-linux-i586.rpm (32-bit)
      • jre-7-linux-x64.rpm (64-bit)
    • JDK 7 (for developers):
      • jdk-7-linux-i586.rpm (32-bit)
      • jdk-7-linux-x64.rpm (64-bit)

      Java 6 downloads
    • JRE 6 (for users who only require the plugin, and the java runtime):
      • jre-6u25-linux-i586-rpm.bin (32-bit)
      • jre-6u25-linux-x64-rpm.bin (64-bit)
    • JDK 6 (for developers):
      • jdk-6u25-linux-i586-rpm.bin (32-bit)
      • jdk-6u25-linux-x64-rpm.bin (64-bit)

  2. Install it:
    If Java 7:
    su -c 'yum install jdk-7-linux-x64.rpm'
    If installing the older Java 6:
    su -c 'sh jdk-6u25-linux-x64-rpm.bin'
    Press ENTER when prompted. Firefox will open (as root) if running X; close it immediately.

  3. Configure Fedora to use the Sun Java browser plugin instead of OpenJDK's
    • If JRE (32-bit):
      su -c 'alternatives --install /usr/lib/mozilla/plugins/ /usr/java/default/lib/i386/ 20000'
    • If JRE (64-bit):
      su -c 'alternatives --install /usr/lib64/mozilla/plugins/ /usr/java/default/lib/amd64/ 20000'
    • If JDK (32-bit):
      su -c 'alternatives --install /usr/lib/mozilla/plugins/ /usr/java/default/jre/lib/i386/ 20000'
    • If JDK (64-bit):
      su -c 'alternatives --install /usr/lib64/mozilla/plugins/ /usr/java/default/jre/lib/amd64/ 20000'

      Test the plugin out at:
      A browser restart is not always required.

  4. Configure Fedora to use the Sun 'java' runtime (JRE-only) and all the other java utils (JDK)

    1. METHOD #1: Using a PATH override

      Run the following as root to create the path override file

      cat <<EOF>> /etc/profile.d/
      export JAVA_HOME=/usr/java/default
      export PATH=\$JAVA_HOME/bin:\$PATH

      Logout then log back in for the new $PATH environment to take effect globally (or run "source /etc/profile.d/" to set the PATH for the current session)

      NOTE: To switch back to using OpenJDK when using this PATH override, you either need to uninstall sun java (yum remove jdk sun-javadb\*), or remove or comment out the PATH override set in

    2. METHOD #2: Using /etc/alternatives
      This is the more "correct" way to switch between *ALL* of Sun Java and OpenJDK, but it's quite a bit more unwieldy. Hopefully at some point Sun will set the alternatives up themselves when their rpm packages are installed:
      TODO: rewrite the paths below using /usr/java/default/{jre/}* as a base depending on JRE/JDK; not sure how to handle the other alternatives in /usr/lib
      rpm -q --scripts java-1.6.0-openjdk         # JRE
      rpm -q --scripts java-1.6.0-openjdk-devel   # JDK


How to test

Test the plugin out at:

Common problems and fixes

More Information


We test this stuff on our own machines - really we do - but you may run into problems; if you do, come to #fedora on

Added Reading

Document Actions
Log in

Forgot your password?
New user?