This tutorial will help to install Java on Fedora Linux. Let’s follow the below simple steps for the installation. The Oracle Java 8 and Java 11 required subscription to download and install. So we use OpenJDK for this installation to run Java on Fedora 32/31/30/29/28/27 Linux system.
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.
Install JAVA 11:
sudo dnf install java-11-openjdk
Install JAVA 8:
sudo dnf install java-1.8.0-openjdk
Step 3 – Check Java Version
I have installed both Java version 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 -version openjdk 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 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 -version openjdk version "11.0.6" 2020-01-14 OpenJDK Runtime Environment 18.9 (build 11.0.6+10) OpenJDK 64-Bit Server VM 18.9 (build 11.0.6+10, mixed mode, sharing)