How to Install Java in Fedora

Channel: Fedora Linux
Abstract: Search OpenJDK Version in Fedora 2. Run the following command to install selected OpenJDK version. $ sudo dnf install java-11-openjdk.x86_64we will sh

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

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

$ sudo dnf install java-11-openjdk.x86_64
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 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

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

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

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.

Ref From: tecmint
Channels: Fedora Tips

Related articles