> ## Content Index
> Fetch the complete content index at: https://itsfoss.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Install Java on Fedora Linux
- URL: https://itsfoss.com/install-java-fedora/
- Published: 2021-08-06T11:46:23.000Z
- Updated: 2023-02-25T14:34:43.000Z
- Description: Learn how to install Java on Fedora. Also learn how to switch between installed versions of Java.
- Author: Abhishek Prakash
- Tags: Fedora

Love it or hate it, it is difficult to avoid Java.

Java is still a very popular programming language taught in the schools and used in the enterprises.

If you want to use a Java-based tool or program in Java, you’ll need to have Java on your system.

This becomes confusing because there are so many technical terms around java.

- Java Development Kit (JDK) for creating Java programs
- Java Runtime Environment (JRE) or Java Virtual Machine (JVM) for running Java programs

On top of that, you’ll come across [OpenJDK](https://openjdk.java.net/?ref=itsfoss.com) and [Oracle Java SE](https://www.oracle.com/java/technologies/javase-downloads.html?ref=itsfoss.com). OpenJDK is what is recommended because it is open source. If you have exclusive need then only you should go for Oracle Java SE.

There is one more thing here. Even OpenJDK has several versions available. At the time of writing this article, Fedora 34 has OpenJDK 1.8, OpenJDK 11 and OpenJDK 16 available.

It is up to you to decide which Java version you want.

## Installing Java on Fedora Linux

First thing first, check if Java is already installed and which version it is. I am not kidding. Fedora usually comes with Java preinstalled.

To check, use the following command:

```
java -version
```

As you can see in the screenshot below, I have Java 11 (OpenJDK 11) installed on my Fedora system.

![check java version fedora](https://itsfoss.com/content/images/wordpress/2021/08/check-java-version-fedora-800x271.png)

Check Java version

Let’s say you want to install another version of Java. You may check the available options with the following command:

```
sudo dnf search openjdk
```

The sudo here is not required but it will refresh the metadata for sudo user which will eventually help when you install another version of Java.

The above command will show a huge output with plenty of similar looking packages. You have to focus on the initial few words to understand the different versions available.

![available java versions fedora](https://itsfoss.com/content/images/wordpress/2021/08/available-java-versions-fedora-800x366.webp)

Available Java versions in Fedora

For example, to install Java 8 (OpenJDK 1.8), the package name should be java-1.8.0-openjdk.x86\_64 or java-1.8.0-openjdk. Use it to install it:

```
sudo dnf install java-1.8.0-openjdk.x86_64
```

![install java fedora](https://itsfoss.com/content/images/wordpress/2021/08/install-java-fedora-800x366.png)

Install Java Fedora

That’s good. Now you have both Java 11 and Java 8 installed on your system. But how will you use one of them?

## Switch Java version on Fedora

Your Java version in use remains the same unless you explicitly change it. Use this command to list the installed Java versions on your system:

```
sudo alternatives --config java
```

You’ll notice a number before the Java versions. The + sign before the Java versions indicate the current Java version in use.

You can specify the number to switch the Java version. So, in the example below, if I enter 2, it will change the Java version on the system from Java 11 to Java 8.

![Switching between installed Java versions](https://itsfoss.com/content/images/wordpress/2021/08/switch-java-versions-fedora-800x513.png)

Switching between installed Java versions

That’s all you need to do to install Java on Fedora.