Step-by-Step Guide- How to Install Java on Linux Systems Efficiently
How do I install Java on Linux? This is a common question among Linux users who need to run Java applications or develop Java-based software. Java is a widely-used programming language and platform, and it’s essential for many tasks. In this article, we’ll guide you through the process of installing Java on various Linux distributions, including Ubuntu, CentOS, and Fedora.
Before we dive into the installation process, it’s important to note that there are two main versions of Java: OpenJDK and Oracle JDK. OpenJDK is an open-source implementation of Java, while Oracle JDK is a commercial version provided by Oracle Corporation. For most users, OpenJDK is sufficient, but if you require additional features or support, you may opt for Oracle JDK.
Let’s start by installing OpenJDK on Ubuntu, one of the most popular Linux distributions.
Install Java on Ubuntu
1. Update your package lists:
sudo apt update
2. Install OpenJDK 8 or 11:
sudo apt install openjdk-8-jdk
or
sudo apt install openjdk-11-jdk
3. Verify the installation:
java -version
After running the above command, you should see the version of Java you installed. If the installation was successful, you’ll see the output similar to the following:
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment (build 11.0.9+10-Ubuntu-0ubuntu1.20.04.1)
OpenJDK 64-Bit Server VM (build 11.0.9+10-Ubuntu-0ubuntu1.20.04.1, mixed mode, sharing)
Now you have successfully installed Java on your Ubuntu system.
Install Java on CentOS
1. Enable the EPEL repository:
sudo yum install epel-release
2. Install OpenJDK 8 or 11:
sudo yum install java-1.8.0-openjdk
or
sudo yum install java-11-openjdk
3. Verify the installation:
java -version
After running the above command, you should see the version of Java you installed. If the installation was successful, you’ll see the output similar to the following:
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment (build 11.0.9+10-Ubuntu-0ubuntu1.20.04.1)
OpenJDK 64-Bit Server VM (build 11.0.9+10-Ubuntu-0ubuntu1.20.04.1, mixed mode, sharing)
Now you have successfully installed Java on your CentOS system.
Install Java on Fedora
1. Install OpenJDK 8 or 11:
sudo dnf install java-8-openjdk
or
sudo dnf install java-11-openjdk
2. Verify the installation:
java -version
After running the above command, you should see the version of Java you installed. If the installation was successful, you’ll see the output similar to the following:
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment (build 11.0.9+10-Ubuntu-0ubuntu1.20.04.1)
OpenJDK 64-Bit Server VM (build 11.0.9+10-Ubuntu-0ubuntu1.20.04.1, mixed mode, sharing)
Now you have successfully installed Java on your Fedora system.
By following these steps, you should now have Java installed on your Linux system. Happy coding!