Java is a popular programming language for the application, system software, and web applications. The Oracle Java 8 and Java 11 required a subscription to download and use it. So we use OpenJDK for this installation of Java on the Fedora Linux system.
This tutorial will help to install Java on Fedora Linux. Let’s follow the below simple steps for the installation.
Step 1 – Search Java Packages
The OpenJDK rpm packages are available under the AppStream repository. Use the following command to search available Java packages under configured DNF repositories.
sudo dnf search openjdk
Step 2 – Install Java on Fedora
Now, use one of the following commands to install the required Java version on your Fedora Linux system. You can also install the both Java version on any system and use as per your requirements.
Choose one of the below commands to install required Java version on Fedora:
- Install Java 11 on Fedora:
sudo dnf install java-11-openjdk
- Installing Java 8 on Fedora:
sudo dnf install java-1.8.0-openjdk
- Install Latest Java on Fedora:
sudo dnf install java-latest-openjdk
You can also install multiple or all versions of Java on a Fedora system. In the next steps, we have provides you instructions to switch between the Java versions on Fedora Linux.
Step 3 – Check Java Version
I have installed both Java versions for this article, First I have installed Java 11 then installed Java 8 on my Fedora system. Let’s check the installed and current active Java version on your system using the following command:
java -versionopenjdk version "1.8.0_242" OpenJDK Runtime Environment (build 1.8.0_242-b08) OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
Step 4 – Switch Between Java Versions
You can use the alternatives command to switch between multiple Java versions installed on your Fedora Linux systems.
sudo alternatives --config java
A list of installed Java versions will be displayed. Select the appropriate Java version number and press enter. In my case, Java 8 is currently active so I entered 1 in selection to change it to Java 11.
After change again check the current active Java version.
java -versionopenjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment 18.9 (build 11.0.11+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.11+9, mixed mode, sharing)
In this tutorial, you have learned to install Java on Fedora Linux systems.