How To Install Java On Fedora [Linux]

Danny Stieben 20-10-2011

installing java on linuxUnder Linux, there are two different implementations of Java that are available for use. The open source variety that most distributions include by default is known, as a whole, as OpenJDK. The other solution, not included by default in most distributions because of its proprietary nature, is Oracle Java (formerly Sun Java). Both work very well, except that Oracle Java might have a few more fixes. In terms of codebase, they are 98-99% identical.


Ubuntu and Arch How To Install Arch Linux On Your Computer [Part 1] During my couple of months here at MakeUseOf, I've mentioned Arch Linux (hereafter simply called "Arch") a couple of times. However, Arch has never really been covered here, so people may still be a little... Read More let you easily install either implementation, while Fedora Linux Just Got Better With The Fedora 16 Beta Distribution Linux distributions have been improving by leaps and bounds, and those improvements are becoming visible in the latest beta releases. Fedora, one of the flagship distributions carrying GNOME 3, is no different and should have... Read More users will have a slightly tougher time (at least when it comes to installing Oracle Java). This article should clear up any of the confusion on how to get it working, including some tips and tricks I discovered for 64-bit users.

Installing OpenJDK (Easy)

installing java on linux
Installing the OpenJDK implementation is actually fairly simple. In order to get all Java functionality, you should run this command to install needed packages if they’re not installed already:

sudo yum install icedtea-web java-1.6.0-openjdk

. This installs the Java Runtime Environment and the needed browser plugins to get a complete working Java system. You can also install those two packages via the package manager.

Installing Oracle Java (Harder)

Simple, right? Well, sadly some Java programs seem to require Oracle Java in order to work correctly, though not everyone has this problem. I’m going to split this into two sections, one for 32-bit users and one for 64-bit users. You can then skip the section that doesn’t apply to your system.

Downloading Files

installing linux fedora
Before we split off into the separate paths, all users can at least download the required files. 32-bit users can either download the JRE from here or the 32-bit JDK from here, while 64-bit users should only choose the 64-bit JDK (I’ll explain why later). Make sure that when you download your file, you choose the one that specifically mentions RPM, which is what Fedora uses. For the sake of simplicity, save the downloaded file in your Downloads folder. Additionally, for the time being, I recommend you still use the Java 6 packages, such as 6u27 at the time of this article, rather than Java 7 because it is still too new.



In order to get the setup to run, you’ll need to open a terminal and run

 chmod +x /home/<user>/Downloads/<filename>

to add executable permissions to the file, and then run it by simply run it by typing


. Don’t forget to substitute <user> with your actual username and <filename> with the name of the file that you downloaded. Go through the setup until it completes.


Congratulations! Oracle Java is already installed on your system! However, you’re still a couple steps away from actually being able to use it. We need to create a lot of symbolic links in multiple places for the system to be able to use it correctly. Note that these commands mention folders such as “jre1.6.0_27” or “jdk1.6.0_27”, which refers to the version 6u27. If you downloaded a different version, say 6u29, you’ll need to edit the path appropriately.


32-bit JRE

If you chose the 32-bit JRE, you’ll need to enter in these commands in order:

  1. sudo alternatives --install /usr/bin/java java /usr/java/jre1.6.0_27/bin/java 20000
  2. sudo alternatives --install /usr/bin/javaws javaws /usr/java/jre1.6.0_27/bin/javaws 20000
  3. sudo alternatives --install /usr/lib/mozilla/plugins/ /usr/java/jre1.6.0_27/lib/i386/ 20000

32-bit JDK

If you chose the 32-bit JDK, you’ll need to enter in these commands in order:

  1. sudo alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_27/jre/bin/java 20000
  2. sudo alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.6.0_27/jre/bin/javaws 20000
  3. sudo alternatives --install /usr/lib/mozilla/plugins/ /usr/java/jdk1.6.0_27/jre/lib/i386/ 20000
  4. sudo alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_27/bin/javac 20000
  5. sudo alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_27/bin/jar 20000

64-bit JDK

Through personal experience, I’ve found that 64-bit users will have to do a few things differently. I asked that you download the 64-bit JDK instead of the 64-bit JRE because the JDK includes a working Java Web Start application while the JRE does not. Additionally, you’ll have to use a few tricks in order to get that to work. Therefore, please use these commands in order:

  1. sudo alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_27/jre/bin/java 20000
  2. sudo alternatives --install /usr/lib64/mozilla/plugins/ /usr/java/jdk1.6.0_27/jre/lib/amd64/ 20000
  3. sudo alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_27/bin/javac 20000
  4. sudo alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_27/bin/jar 20000
  5. sudo ln -s /usr/java/jdk1.6.0_27/jre/javaws/javaws /etc/alternatives/javaws
  6. sudo ln -s /etc/alternatives/javaws /usr/bin/javaws

What those commands do differently is install the 64-bit browser plugin rather than the 32-bit plugin as well as use a different way of creating the necessary links for javaws, as the other way did not work for me.


Final Steps

installing linux fedora
Last but not least, you’ll need to edit a file and add in a line of text. To do that, you can open your favorite text editor to change the /home/<user>/.bash_profile file. If you installed the JDK (32-bit or 64-bit), add:

## export JAVA_HOME JDK ##
export JAVA_HOME="/usr/java/jdk1.6.0_27"

If you installed the JRE, please add:

## export JAVA_HOME JRE ##
export JAVA_HOME="/usr/java/jre1.6.0_27"


installing java on linux
Java has finally been installed and configured correctly! You should now be able to use Java wherever you may need it, including Firefox. If you use a different browser, you can create a link from the Firefox location to your browser’s plugin folder. Although it’s quite a bit of work, it’ll pay off in the long run.

What do you prefer, OpenJDK or Oracle Java? Would you like to see Oracle completely open-source Java and maintain one single implementation? Why or why not? Let us know in the comments!


Related topics: Fedora, Java.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Danielson Jùnior
    January 23, 2015 at 7:39 pm

    I had some troubles with open-jdk when, here at the job, we compiled a ".war" file and it didn't work out at JBoss AS 6. We only solved creating the file with Oracle Java.

    Thank for your post!!

  2. Inukaze Maquiavelo
    December 1, 2011 at 2:10 am

    I need install under Fedora16 x86_64 , with lastest kernel

    The OpenJDK , 32 Bits & 64 Bits , both
    some games just use the "32 Bits" openjdk like "SpiralKnight" or "Wakfu"