How to do a custom installation of Java

Back to the Unofficial Fedora FAQ


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 java.sh 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 java.sh in /etc/profile.d/

    The easiest way to do this is:

    gedit /etc/profile.d/java.sh

    If you're not in a graphical environment:

    nano /etc/profile.d/java.sh

  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.sh

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/libjavaplugin_oji.so /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/libjavaplugin_oji.so ~/.mozilla/plugins/

(Thanks to Matt Labrum for that suggestion.)

For the SDK, the plugin is:

/usr/java/<YourJavaDirectory>/jre/plugin/i386/ns610-gcc32/libjavaplugin_oji.so

(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.)