Java is an extremely popular programming language used worldwide for countless programs and services. To run these Java-based programs, Java must be installed on the system. Below, you will learn how to install Java on your system for the supported Linux operating systems.
Before starting the actual Java installation, you should ensure your system is up to date. For this, we connect to the server via SSH. If you don’t know what SSH is or how to use it, it’s best to check out this guide: First Access (SSH)
Once connected, you can update the system depending on the operating system with the following command:
// Debian
sudo apt-get update
// Ubuntu
sudo apt update
// CentOS
sudo yum update
// OpenSUSE
sudo zypper up
// Fedora
sudo dnf upgrade --refresh
After preparation, you can start installing Java. Depending on your operating system, run the following commands:
Debian
sudo apt-get install default-jdk
Ubuntu
sudo apt install default-jdk
CentOS
sudo yum install java-11-openjdk
Fedora
sudo dnf install java-11-openjdk
You can verify if the installation was successful with the command java --version. The output should look similar to this:
openjdk 11.0.9.1 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04, mixed mode)
In this case, Java 11 was successfully installed on your system. Now you can easily start your Java applications on your system.