Hello, friends. In this post, you will learn how to install Java on Ubuntu 22.04.
As we all know, Java is a very popular programming language and software platform. Thus, Java is indispensable for many Linux developers and professionals who need it to either develop applications or run other applications already created.
Java is available for installation on Linux without too many problems. In this case, we will opt for the OpenJDK version, which is community maintained and fully compatible with the Oracle version.
So let’s go for it.
Install Java on Ubuntu 22.04
Fortunately, we have several versions of Java in the official repositories of Ubuntu 22.04. These different versions can coexist on the system without many issues. However, we usually install one of them.
The versions of Java that can be found in the Ubuntu 22.04 repositories are 8, 11 and 17.
Versions 8 and 11 are LTS, meaning that they are supported for quite a while longer. These are the recommended versions to use. While 17 is the latest stable version.
For this example, we will install version 11 which is one of the most stable versions and combines robustness with newness. Ideal for many applications and serve as a base for others.
To install Java on Ubuntu 22.04 just run the following command
sudo apt update sudo apt install openjdk-11-jdk
But if you only want the JRE, i.e., you are not going to develop but only run Java applications, it may be convenient not to install everything.
If this is your case, you can install only the JRE by running
sudo apt install openjdk-11-jre
This will start the whole installation, which shouldn’t take too long.
Then, you can verify the changes by displaying the Java version.
java --version openjdk 220.127.116.11 2022-02-08 OpenJDK Runtime Environment (build 18.104.22.168+1-Ubuntu-0ubuntu1) OpenJDK 64-Bit Server VM (build 22.214.171.124+1-Ubuntu-0ubuntu1, mixed mode, sharing)
That’s how easy it is to get Java on your system.
If you want to learn how to set the JAVA_HOME variable on your system, you can take a look at our post.
How to Set JAVA HOME Path in Ubuntu 20.04
This post can help you a lot.
Thanks to this post, you learned how to install Java quickly and easily. I hope you liked this post and help us to keep growing.