How to Choose Your Default Java Version on Fedora Linux

Choosing the default Java version on your Fedora Linux system can be confusing, especially if you have multiple versions installed. This guide will walk you through the steps to select which version of Java is used by default.

In Fedora Linux, you may have multiple versions of Java installed, and it’s essential to choose the one that should be used as the default. Here are the steps to follow:


To find out which version of Java is currently set as the default, open a terminal or console and use the following command:

/usr/sbin/alternatives --config java

This command will list all the Java versions installed on your system, along with the program that provides them. For example:

There are 3 programs which provide 'java'.

Selection Command
-----------------------------------------------
+ 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
* 3 /usr/java/default/bin/java
Enter to keep the current selection[+], or type selection number:

As you can see, there are three versions of Java installed: OpenJDK, GCJ, and Java (Sun).


To select which version should be used as the default, simply enter the number corresponding to your chosen version. For example, if you want to use OpenJDK as the default, enter 1 when prompted.

+ 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
* 3 /usr/java/default/bin/java

Enter to keep the current selection[+], or type selection number: 1

Press ENTER to confirm your selection.


Once you’ve selected a version, it will be used as the default by all Java programs on your system. This means that any new applications you install or software updates you run should use the chosen version of Java without needing further configuration.

By following these steps, you can ensure that your Fedora Linux system uses the correct version of Java as its default.