How To Install Java On Fedora [Linux]

Ads by Google

java logo   How To Install Java On Fedora [Linux]Under 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 let you easily install either implementation, while Fedora 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)

fedora openjdk install   How To Install Java On Fedora [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.

Ads by Google

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

java jdk download   How To Install Java On Fedora [Linux]
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.

Installation

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

/home/<user>/Downloads/<filename>

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

Configuration

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/libjavaplugin.so libjavaplugin.so /usr/java/jre1.6.0_27/lib/i386/libnpjp2.so 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/libjavaplugin.so libjavaplugin.so /usr/java/jdk1.6.0_27/jre/lib/i386/libnpjp2.so 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/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jdk1.6.0_27/jre/lib/amd64/libnpjp2.so 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

java bashprofile   How To Install Java On Fedora [Linux]
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"

Conclusion

java browser plugin   How To Install Java On Fedora [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!

Ads by Google

The comments were closed because the article is more than 180 days old.

If you have any questions related to what's mentioned in the article or need help with any computer issue, ask it on MakeUseOf Answers—We and our community will be more than happy to help.

One Comment -

Inukaze Maquiavelo

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”