Java is a computing, object-oriented, powerful programming language introduced by Sun Microsystems. It is widely used to build many services and applications. The Desktop and Android applications are the primary examples of it. Java is a class-based programming language and also supports a multi-threading environment. It is more similar to C++.
We will examine the Java installation method on Ubuntu 22.04 in this blog.
How to install Java on Ubuntu 22.04?
To install Java on Ubuntu 22.04, follow the steps mentioned below.
Step 1: Update system packages
First, open the Ubuntu 22.04 terminal by using “CTRL+ALT+T” and update the packages of the system:
$ sudo apt update
Move to the next step.
Step 2: Install necessary packages
Install the ”libc6-x32” math standard library and “libc6” library for 32-bit architecture system:
$ sudo apt install -y libc6-x32 libc6-i386
Continue to download the JDK 18 setup file.
Step 3: Download setup file of JDK 18
Use the “wget” command to download setup file of JDK 18:
$ wget https://download.oracle.com/java/18/latest/jdk-18_linux-x64_bin.deb
Step 4: Install Java
Install Java by installing JDK 18 on the system:
$ sudo apt install ./jdk-18_linux-x64_bin.deb
Let’s move further to do some initial configuration.
Step 5: JDK 18 configuration
Configure and export the Java environment by executing the below-listed commands one after one:
$ cat <<EOF | sudo tee /etc/profile.d/jdk18.sh
> export JAVA_HOME=/usr/lib/jvm/jdk-18
> export PATH=\$PATH:\$JAVA_HOME/bin
> EOF
Step 6: JDK profile execution
Finally, execute the JDK 18 profile file:
$ source /etc/profile.d/jdk18.sh
Step 7: Confirm Java version
Confirm the Java installation by verifying its version:
$ java -version
From the above output, you can see that we have successfully installed Java version “18.0.1.1” on Ubuntu 22.04. Let’s move ahead to remove Java from Ubuntu 22.04.
How to remove Java from Ubuntu 22.04?
On Ubuntu 22.04, to remove Java and its related directories, execute the provided command:
$ sudo rm -rf /usr/lib/jvm/*
We have discussed the complete procedure for Java installation and removal on Ubuntu 22.04.
Conclusion
To install Java on Ubuntu 22.04, first, update the system packages. Then, install additional libraries that support Java. After that, download the JDK 18 setup file and install it by using the “$ sudo apt install ./jdk-18_linux-x64_bin.deb” command. In this write-up, we have demonstrated all the essential instructions to install and remove Java on Ubuntu 22.04.
TUTORIALS ON LINUX, PROGRAMMING & TECHNOLOGY