LOGO

Install Java on Fedora Linux - A Step-by-Step Guide

October 20, 2011
Install Java on Fedora Linux - A Step-by-Step Guide

Java Implementations on Linux

When working within a Linux environment, two distinct Java implementations are accessible for utilization. The predominantly included, open-source version across many distributions is collectively referred to as OpenJDK.

Alternatively, Oracle Java (previously known as Sun Java) presents another option. Its exclusion from most default distributions stems from its proprietary licensing.

Both implementations function effectively, though Oracle Java may incorporate a slightly greater number of bug fixes. Their underlying codebases share a remarkable degree of similarity, estimated at 98-99%.

Installation Across Distributions

Users of Ubuntu and Arch Linux benefit from straightforward installation processes for either Java version. However, Fedora users may encounter increased complexity, particularly when attempting to install Oracle Java.

This guide aims to resolve any ambiguity surrounding the installation process. It will provide clear instructions and helpful techniques, especially for those operating on 64-bit systems.

The following points will be covered to ensure a smooth installation experience:

  • Detailed steps for installing OpenJDK.
  • Instructions for installing Oracle Java on various distributions.
  • Troubleshooting tips for common installation issues.
  • Specific guidance for 64-bit Linux systems.

Successfully installing and configuring Java is crucial for running a wide range of applications. This article will empower you to choose and implement the Java version best suited to your needs.

Installing OpenJDK (Simplified)

The process of installing the OpenJDK implementation is generally quite straightforward. To ensure full Java functionality, execute the following command to install any required packages that may not already be present on your system:

sudo yum install icedtea-web java-1.6.0-openjdk

This command installs both the Java Runtime Environment and the necessary browser plugins. These components work together to provide a fully functional Java environment.

Package Manager Installation

Alternatively, the Java Runtime Environment and associated browser plugins can be installed directly through the system's package manager. This offers a convenient method for managing Java dependencies.

Utilizing the package manager ensures that all required components are installed and configured correctly, leading to a seamless Java experience.

Installing Oracle Java (A More Involved Process)

The installation process appears straightforward initially. However, certain Java applications may necessitate the use of Oracle Java for proper functionality, although this isn't a universal requirement. This guide will be divided into two distinct sections, catering to 32-bit and 64-bit system users respectively. Users can bypass the section irrelevant to their system architecture.

Acquiring the Necessary Files

Prior to diverging into system-specific instructions, all users can proceed with downloading the required files. 32-bit system users have the option of downloading either the Java Runtime Environment (JRE) or the 32-bit Java Development Kit (JDK). 64-bit users should exclusively select the 64-bit JDK; the rationale for this will be explained shortly.

Ensure that the downloaded file specifically indicates RPM compatibility, as this is the package format utilized by Fedora. For ease of access, save the downloaded file within your Downloads directory. Currently, it is advisable to utilize Java 6 packages, such as 6u27, over Java 7 due to the latter’s relative immaturity.

Performing the Installation

To initiate the installation process, a terminal window must be opened. Then, execute the following command:

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

This command grants executable permissions to the downloaded file. Subsequently, the file can be executed by typing:

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

Remember to replace <user> with your actual username and <filename> with the precise name of the downloaded file. Proceed through the installation wizard until completion.

Java Configuration

Oracle Java has been successfully installed on your operating system. However, further configuration is required to enable its functionality. This involves establishing several symbolic links to ensure the system can correctly utilize the Java installation.

Please note that the commands provided reference directory names like "jre1.6.0_27" or "jdk1.6.0_27," corresponding to version 6u27. If a different version was downloaded, such as 6u29, adjust the paths accordingly.

32-bit JRE Setup

For those who opted for the 32-bit JRE, execute the following commands sequentially:

  • sudo alternatives --install /usr/bin/java java /usr/java/jre1.6.0_27/bin/java 20000

  • sudo alternatives --install /usr/bin/javaws javaws /usr/java/jre1.6.0_27/bin/javaws 20000

  • 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 Setup

If the 32-bit JDK was chosen, the following commands must be entered in the specified order:

  • sudo alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_27/jre/bin/java 20000

  • sudo alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.6.0_27/jre/bin/javaws 20000

  • sudo alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk1.6.0_27/jre/lib/i386/libnpjp2.so 20000

  • sudo alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_27/bin/javac 20000

  • sudo alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_27/bin/jar 20000

64-bit JDK Configuration

Based on experience, 64-bit system users may require a slightly different approach. Downloading the 64-bit JDK is recommended, as it includes a functional Java Web Start application, which is absent in the 64-bit JRE. The following commands should be executed in order:

  • sudo alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_27/jre/bin/java 20000

  • 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

  • sudo alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_27/bin/javac 20000

  • sudo alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_27/bin/jar 20000

  • sudo ln -s /usr/java/jdk1.6.0_27/jre/javaws/javaws /etc/alternatives/javaws

  • sudo ln -s /etc/alternatives/javaws /usr/bin/javaws

These commands ensure the installation of the 64-bit browser plugin and establish the necessary links for Java Web Start, addressing compatibility issues encountered with alternative methods.

Completing the Setup

install-java-fedora-linux-3.jpg

Finally, a configuration file must be modified. Open your preferred text editor and modify the /home// .bash_profile file. If the JDK (either 32-bit or 64-bit) was installed, add the following:

## export JAVA_HOME JDK ##

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

If the JRE was installed, add this line instead:

## export JAVA_HOME JRE ##

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

Conclusion

The Java installation and configuration process is now complete. You are now equipped to utilize Java in various applications, including the Firefox web browser.

For users employing alternative browsers, a symbolic link can be established from the Firefox plugins directory to the corresponding plugin folder of their preferred browser. While this may require some effort, the benefits will be realized over time.

Your Preferences Matter

Consider whether you favor OpenJDK or Oracle Java. Do you believe Oracle should fully open-source Java, consolidating development into a single implementation?

We encourage you to share your thoughts and reasoning in the comments section below. Your feedback is valuable!

#Java#Fedora#Linux#installation#tutorial#guide