Last Updated on 19 hours by Sachin G
Setting up Java is one of the first tasks for many Linux developers, whether they’re building applications, running development servers, or learning the Language. In this post, I will explain the steps to install OpenJDK on Ubuntu and LinuxMint on Ubuntu and Linux Mint. Whether you prefer using OpenJDK from official repositories or installing the Oracle JDK manually via .deb
packages, this post covers both methods. Additionally, I will show you how to verify your installation and configure the default Java version when multiple versions are installed.
Why Install OpenJDK on Ubuntu or LinuxMint?
Java remains one of the most widely used programming languages globally, and the OpenJDK is the go-to open-source Java implementation. It’s supported by Canonical and is preferred for both local development and server-side deployments on Linux.
Java remains one of the most widely used, powerful, and versatile programming languages and is a cornerstone in various software development projects, server-side applications, and enterprise solutions. To harness the latest features, enhancements, and security updates, installing the latest Java OpenJDK version on your Ubuntu or Linux Mint system is crucial.
Unlike Oracle JDK, OpenJDK is fully open-source, with no licensing concerns. That makes it ideal for startups, students, and enterprise environments alike.
If you aim to install on RPM-based operating systems such as CentOS, AlmaLinux, or Oracle Linux, you can refer to our other article. Click Here to view.
Note: Screenshots shown here may reflect earlier JDK versions or older Ubuntu/LinuxMint themes. However, the process remains fully compatible with the latest releases.
How to Install OpenJDK on Ubuntu 22.04 (and later)
The apt package manager simplifies the process of installing and managing software packages on Ubuntu and Linux Mint systems. Follow these steps to install the latest Java version using the apt command.
By default, the OpenJDK package is available in Ubuntu repositories, and you can check its availability as demonstrated.
sudo apt-cache search openjdk
After filter, which openjdk version do you want to install then you can proceed to install the latest version of Java on your system using the following command:
sudo apt install openjdk-24-jdk
Replace 24 with the desired version number if a newer version is available. This command installs the, which is a popular choice for Java development.
If you’re installing it on a server (without GUI), you can use:
sudo apt install openjdk-24-jdk-headless
These are part of the default Ubuntu repositories and are fully maintained by Canonical.
How to Check Java Version After Installing OpenJDK on Ubuntu
After the installation is complete, verify that the latest version of Java has been successfully installed on your system by checking the installed Java version:
java -version
Expected output:
openjdk version "24" 2025-03-19 OpenJDK Runtime Environment (build 24+36-Ubuntu-1)
You should see the above output similar to the following, indicating the installed Java version
Also check compiler:
javac -version
Step-by-Step Guide to Installing Oracle Java JDK via .deb Package
Follow these steps to install Oracle Java JDK 24 on your Ubuntu or Debian-based system using the .deb package method:
Download the Oracle JDK .deb
Package
Visit the Oracle Java downloads page and download the OpenJDK 24 or which version you would like to install .deb package for your system architecture. Ensure that you download the appropriate package compatible with your system configuration.
Navigate to the Download Directory
Once the download is complete, navigate to the directory where the JDK 24 .deb package is saved. You can typically find it in the “Downloads” directory unless you specify a different location during the download.
cd ~/Downloads
Install the Oracle JDK 24 .deb Package
Use the dpkg package manager to install the Oracle JDK 24 .deb package. Replace jdk-24.deb
with the actual filename of the downloaded package.
sudo dpkg -i jdk-24_linux-x64_bin.deb
If you see dependency errors, run:
sudo apt -f install
This command installs the Oracle JDK 24 package on your system. If any dependencies are missing, dpkg will notify you, and you can resolve them using the apt
package manager.
Verify the Installation
After installation, verify that Oracle JDK 24 has been successfully installed on your system by checking the installed Java version:
java -version
Configure Oracle JDK as the Default Java Version (Optional)
You can have more than one Java installed on your system without big problems. But sometimes you might need to pick one as the main Java, depending on what your projects need. You can do this using the “update-alternatives” command. It helps you see the options and choose which Java you want to use by default.
sudo update-alternatives --config java
After setting the Java version, check the Javac and jar versions respectively via the below command.
javac --version
jar --version
javac and jar versions will remain the same. You can switch both versions through the below command. Take guidance from the screenshot.
sudo update-alternatives --config javac
sudo update-alternatives --config jar
Installing Oracle Java JDK on Ubuntu or Debian-based systems using the apt method or .deb package download method empowers you with the latest tools and features for Java development.
OpenJDK vs Oracle JDK: Which One Should You Use?
While Oracle JDK is officially supported by Oracle and sometimes required for enterprise apps, OpenJDK offers nearly identical features and is preferred for most Linux users due to its open-source nature and easy distribution.
Unless a specific application demands Oracle JDK, installing OpenJDK on Ubuntu or LinuxMint is the smart choice
Where to Download OpenJDK or JDK Packages
You can always manually download tarballs from:
- https://jdk.java.net
- https://openjdk.org
- For Ubuntu-packaged builds: https://launchpad.net
However, for most users, APT-based installation is faster and more secure.
FAQs
Use: sudo apt install openjdk-24-jdk
OpenJDK is the open-source version. Java JDK can refer to Oracle’s proprietary version.
Yes, especially if you use build tools like Maven or Gradle.
Use: sudo apt install openjdk-24-jdk-headless
Run: sudo apt remove openjdk-XX-jdk
Yes, but you must manage versions manually using update-alternatives
It’s not mandatory, but removing OpenJDK avoids version conflicts.
Installing the latest Java JDK on Ubuntu or Linux Mint is easier than ever with the APT package manager. Whether you’re a student learning Java basics or a backend developer working with Spring Boot, OpenJDK is your go-to solution.
I’m Sachin Gupta — a freelance IT support specialist and founder of techtransit.org. I’m certified in Linux, Ansible, OpenShift (Red Hat), cPanel, and ITIL, with over 15 years of hands-on experience. I create beginner-friendly Linux tutorials, help with Ansible automation, and offer IT support on platforms like Upwork, Freelancer, and PeoplePerHour. Follow Tech Transit for practical tips, hosting guides, and real-world Linux expertise!