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.

Tutorial Feedback...
Was this article helpful? If you don't find this article helpful or found some outdated info, issue or a typo, do post your valuable feedback or suggestions in the comments to help improve this article...

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

1 thought on “How to Install Java in Fedora”

  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.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.