How to do a custom installation of Java

Here is how to install Java using Sun's Java RPM:

  1. Go to the Java Runtime Download Page.
  2. Click on "Download J2SE JRE."

    If you want to develop Java software, get the SDK package instead of the JRE, and alter the rest of these directions appropriately. You'll have to set export JDK_HOME="$JAVA_HOME" in the below, as well.

  3. Choose "Accept" and click "Continue."
  4. Click on the link that says "Linux RPM in self-extracting file."
  5. Save the file in your home directory. The download will take a little while.
  6. Open a Terminal.
  7. Type

    sh j2re*rpm.bin

  8. Become root:

    su -

  9. To install the rpm, type:

    rpm -Uvh j2re-*.rpm

    There will be a bit of whirring.

  10. Create a file called in /etc/profile.d/

    The easiest way to do this is:

    gedit /etc/profile.d/

    If you're not in a graphical environment:

    nano /etc/profile.d/

  11. This file should contain the following lines. You have to modify the first line appropriately, according to what's actually in /usr/java/:

    export JAVA_HOME="/usr/java/j2re1.4.2_02"
    export JAVA_PATH="$JAVA_HOME"
    export PATH="$PATH:$JAVA_HOME/bin"

  12. To finish it up, do:

    chmod +x /etc/profile.d/

Java should now work properly. You will need to log in and log out for some things to function properly.

To install the browser plugin for java, as root, do:

ln -sf /usr/java/<YourJavaDirectory>/plugin/i386/ns610-gcc32/ /usr/lib/mozilla/plugins

Replace <YourJavaDirectory> with the name of the actual directory.

If that doesn't work, try this as the user you are logged in as (not root):

ln -sf /usr/java/<YourJavaDirectory>/plugin/i386/ns610-gcc32/ ~/.mozilla/plugins/

(Thanks to Matt Labrum for that suggestion.)

For the SDK, the plugin is:


(Thanks to Rob Hoeft for that.)

(Thanks to Andre Robatino and "m d" for suggesting the /usr/lib/mozilla/ directory instead of the version-specific one. Thanks to Kai Thomsen for noting that you only have to login-logout, not reboot. Thanks to Cymon Cox for the heads-up that Sun's site changed.)

[an error occurred while processing this directive]
This FAQ is maintained by Max Kanat-Alexander. That's max -at- fedorafaq -dot- org or Avatraxiom in #fedora on FreeNode IRC. Sindre "foolish" Pedersen Bjørdal is the Assistant Editor (foolish -at- fedorafaq -dot- org).

You can help us keep this FAQ up to date! if you discover an issue we don't cover, find any errors in the answers already here or have a suggestion of some kind, please contact us and we'll get on it.