In this tutorial we will learn how to install Java on Linux mint.
Java is a very popular language when it comes to programming. It is a common language for android development and other enterprise solutions. The reason Java is so popular is its platform independence.
Before we get into that, there are a few terms we need to be familiar with.
- JRE: Java Runtime Environment: It is a Java environment that you need, to be able to run Java applications successfully. If you are not a programmer and only need Java to run applications, installing this should be sufficient.
- JDK: Java Development Kit: You need to install this if you want to write and run some Java code yourself.
There are two different distributions of Java.
- OpenJDK: This is the open-source implementation of Java. That is to say, it doesn’t require any license to use.
- Oracle JDK: This is the version of Java distributed by Java and requires a license for commercial use.
In this tutorial we will look at OpenJDK as it is also the default version for Linux.
Steps to Install Java on Linux Mint
Before we proceed with the installation, it is a good idea to check whether we already have Java installed.
Use the following command:
$ java -version
If you already have Java installed, you will see the version. Else, you’ll see an output that says “command not found”. After verifying that you do not have Java installed on your system, you can proceed with the steps below.
1. Install Java Runtime Environment
To install Java on Mint, you need to first install JRE. Use the following command for the latest version using the apt command:
$ sudo apt install default-jre
This will install the default version of JRE for you. Alternatively, if you need to install a particular version of Java, you can use the following command.
For Java 8:
$ sudo apt install openjdk-8-jre
For java 7:
$ sudo apt install openjdk-7-jre
And so on. Currently, OpenJDK 14 is the latest version available. It was released on 17th March 2020.
You can refer to OpenJDK’s official website for updates.
Even though the latest version is JDK 14, the default version is OpenJDK 11.
2. Installing Java Development Kit
After installing JRE, next step is installing JDK. The command for that is:
$ sudo apt install default-jdk
For installing Java 8, use:
$ sudo apt install openjdk-8-jdk
For Java 7:
$ sudo apt install openjdk-7-jdk
Make sure your JDK version matches the JRE version.
3. Verifying the installation
After successfully installing JRE and JDK, we can check if Java was correctly installed by using the command :
$ java -version
We can see that OpenJDK 11 was installed successfully.
4. Command to Uninstalling Java
To uninstall Java from your system use the command :
$ sudo apt remove openjdk*
You’ll be prompted to confirm. Press y and enter to continue.
This will successfully uninstall Java from your system.
After going through this tutorial you will be able to install Java on Linux mint. We’ve covered the steps to download and install different versions of Java on Linux Mint since many applications require a specific version of Java to be installed.
I hope this tutorial helped you quickly get through with the installation. If you have any questions, don’t hesitate to put them in the comments below.