This article will show you how to install Java in Linux Mint 20 using the command-line environment. All procedures and commands in this article were implemented using the Linux Mint 20 environment.
Installation of Default Java in Linux Mint 20
Perform the following steps to install Java in the Linux Mint distribution.
Step 1: Open Terminal
First, open the terminal, where you will run all the installation commands. To do so, click on the Linux Mint 20 start menu and select the terminal from the pop-up applications list. You can also open the terminal window using the keyboard shortcut Ctrl + Alt + t.
Step 2: Update apt-cache
Next, update the apt-cache by entering the following command before beginning the installation of Java on your system.
Step 3: Check Java Version
In this step, you will determine whether Java is already installed on your system. In most Linux distributions, Java comes pre-installed. So, using the following command, you can check whether Java is already installed:
If you receive a blank output, then it means that you need to install Java on your system. In the image above, OpenJDK-11 is already installed on the system.
Step 4: Install Java JDK and JRE
You can also install the default Java JRE and JDK components onto your system. To install the default Java JDK packages, issue the following command:
After running the above command, this will start the installation of the JDK packages onto your system. The above installation process will take some time to complete.
To install the default Java JRE packages, issue the following command:
Install Latest Java 14 in Linux Mint 20
At the time of writing this article, the latest available Java version is Java 14. To install Java 14 onto your system, follow the steps given below:
Step 1: Add PPA Linux Uprising
To install Java 14 in Linux Mint 20, you must first add the PPA Linux uprising repository. You can do so by entering the following command:
Press ‘Enter’ to import the gpg key of the uprising PPA.
Step 2: Update apt-cache
Again, update the apt-cache by using the following command:
Step 3: Install Latest Oracle Java 14
Install Oracle Java 14 onto your system using the following command:
The above command will first download the latest version of Java 14 from the official Oracle website. So, be patient while your system completes the download process, as this may take some time.
The following dialog will appear during the installation. Click the ‘OK’ option to sign the agreement.
Again, you will select ‘OK’ to accept the agreement and install Java 14 on your system.
It will take some time to complete the installation.
Now, Java 14 is set as the default version on your system.
You also check the default version by running the following command in the terminal:
Set Default Java Version Manually
You can also change the default Java version and update alternatives on your system by entering the following command:
The above command is useful when multiple Java versions are installed in your Linux system. The following output will display on your system. Using the above command, you can manually set the default Java version in Linux Mint 20. Select and enter the Java version that you want to set as the default. After selecting the default version, you will see the default Java version with a complete path in the terminal window, as shown in the following section.
Check Java Executable Path
You can also check the executable Java path by entering the command below:
After entering this command, the following output will display in your terminal window:
Conclusion
This article showed you how to install Java JDK and JRE packages in Linux Mint 20. The article also showed you how to install multiple Java versions onto your Linux system. You can set the default Java version on your system according to your specific requirements. That is all about the installation of Java in Linux Mint 20. Enjoy!