How to Install Java in Fedora

Java is a general-purpose programming language that is fast, reliable, secure, popular and widely used. It is an environment to develop and run a wide range of applications, from mobile applications to desktop and web applications and enterprise systems – Java is everywhere!

If you are planning to create a program in Java, then you need to install a JDK (Java Development Kit). If you are planning to execute a Java program, you can do that on a JVM (Java Virtual Machine), which is included in the JRE (Java Runtime Environment). If in confusion, install the JDK because this is frequently needed even if the motive is not to create Java programs.

There are many flavors of Java out there and also many versions of each flavor. In this article, we will show you how to install both OpenJDK and Oracle JDK (Oracle Java SE) in Fedora.

Most Java applications run on one of the following:

  • OpenJDK — an open-source implementation of the Java Platform, Standard Edition
  • Oracle Java SE — a free JDK from Oracle

Important: Use the sudo command to gain root privileges while running commands in this article, if you are operating the system as a normal or administrative user.

Installing OpenJDK in Fedora

The package OpenJDK is available to install from the Fedora repository.

1. Run the following dnf command to search for the available versions.

$ sudo dnf search openjdk
Search OpenJDK Version in Fedora
Search OpenJDK Version in Fedora

2. Run the following command to install selected OpenJDK version.

$ sudo dnf install java-11-openjdk.x86_64
Install Java OpenJDK in Fedora
Install Java OpenJDK in Fedora

3. Next, run the following command to verify the version of Java installed on the system.

$ java --version
Verify Java Version in Fedora
Verify Java Version in Fedora

Installing Oracle JDK in Fedora

To install Oracle Java SE:

1. Go to the Oracle Java SE downloads page. Then choose the version of Java you wish to use. To grab the latest version (Java SE 11.0.2 LTS), simply click the DOWNLOAD button as shown in the following image.

Oracle JDK Download
Oracle JDK Download

2. Accept the license agreement and download the appropriate RPM file for your systems architecture, for example jdk-11.0.2_linux-x64_bin.rpm for a 64 bit system.

Download Oracle JDK RPM Package
Download Oracle JDK RPM Package

3. Once the download is complete, on the terminal, move to the Download directory and run the following command to install package.

$ sudo dnf install  jdk-11.0.2_linux-x64_bin.rpm

Note: You might have installed several versions of Java on your system, you can switch from one version to another using the following command.

After running this command, you will see a a list of all installed Java versions, select the version you require.

$ sudo alternatives --config java
$ java --version
Switch Java Version in Fedora
Switch Java Version in Fedora

Java is a general-purpose programming language and environment to develop and run a wide range of programs. In this article, we showed how to install Java (OpenJDK and Oracle JDK) in Fedora. If you have any questions or comments, reach us through the feedback form below.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

1 Comment

Leave a Reply
  1. It doesn’t work. see “Accept the license agreement and download the appropriate tar.gz file for your systems architecture. Do NOT use Oracle rpms as these are NOT compatible with fedora/OpenJDK packages. Download tar.gz instead and unpack it somewhere.” in https://docs.fedoraproject.org/en-US/quick-docs/installing-java/.

    But the last doesn’t work too because the archive doesn’t contain any rpm which suggested to install with the command “sudo dnf install version-downloaded.rpm“.

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.