How to Install Oracle Java JDK 18 on Linux
Java 18 (Non-LTS) is the latest and current release for the Java SE platform. This newest release includes JDK 18, which provides a development environment for building applications using the Java programing language and testing and running the Java programs.
READ: Java SE 18 Release Notes
Here, we will see how to install Java JDK 18 on Linux.
Install Oracle Java JDK 18 on Linux
Install Oracle Java JDK 18 on CentOS / RHEL / Rocky Linux & Fedora
First, switch to the root user if required.
sudo su -
Then, download Oracle Java JDK 17 using the wget
command in the terminal.
curl -O https://download.oracle.com/java/18/latest/jdk-18_linux-x64_bin.rpm
And then, install Oracle Java JDK 18 using the rpm
command.
rpm -ivh jdk-18_linux-x64_bin.rpm
Install Oracle Java JDK 18 on Ubuntu / Debian
Install the below dependencies for Oracle Java JDK.
sudo apt update sudo apt install -y libc6-x32 libc6-i386
But, first, download Oracle Java JDK 18 using the wget
command in the terminal.
wget https://download.oracle.com/java/18/latest/jdk-18_linux-x64_bin.deb
Then, install Oracle Java JDK 18 using the dpkg
command.
sudo dpkg -i jdk-18_linux-x64_bin.deb
In some cases, you may need to install Oracle JDK 18 on the PATH
location.
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-18/bin/java 1
Verify Java JDK Installation
After the installation of Java, use the below command to verify the version.
java -version
Output:
java version "18.0.1" 2022-04-19 Java(TM) SE Runtime Environment (build 18.0.1+10-24) Java HotSpot(TM) 64-Bit Server VM (build 18.0.1+10-24, mixed mode, sharing)
Conclusion
That’s All. I hope you have learned how to install Java JDK 18 on Linux.