Java remains one of the most widely used programming platforms for servers, enterprise applications, Android development, and modern build tools. If you want to install Java Ubuntu systems correctly, Ubuntu 24.04 provides several reliable options including OpenJDK and Oracle JDK.
This guide explains how to install Java on Ubuntu 24.04, switch between multiple Java versions, and configure the JAVA_HOME variable for development environments.
Many developers rely on Java for frameworks like Spring Boot, Gradle, Maven, and Apache Tomcat. Ubuntu 24.04 supports multiple Java releases, making it easier to run both older and modern applications without compatibility issues.
The two most common Java implementations are:
OpenJDK is open-source and comes directly from Ubuntu repositories, while Oracle JDK is maintained by Oracle with separate licensing terms.
Before installation, check whether Java is already available on your system:
java -version
If Java is missing, update your package index first:
sudo apt update
Ubuntu 24.04 includes OpenJDK packages directly through its repositories. To install the latest OpenJDK version, run:
sudo apt install openjdk-25-jdk
Once installed, verify the setup:
java -version
You should now see the installed Java version displayed in the terminal.
Some applications still depend on Java 21 for long-term compatibility. Ubuntu’s default Java package uses this version.
Install it with:
sudo apt install default-jdk
You can also manually install Java 21:
sudo apt install openjdk-21-jdk
This option is ideal for projects that are not yet optimized for newer Java releases.
If your application specifically requires Oracle Java, download the official Debian package from Oracle’s website.
After downloading the .deb file, install it using:
sudo apt install ./jdk-25_linux-x64_bin.deb
Oracle JDK is commonly used in enterprise environments where vendor-specific support is required.
If multiple Java versions are installed, Ubuntu allows you to choose the default version easily.
Run:
sudo update-alternatives --config java
You will see a list of installed Java versions. Select the preferred version number and press Enter.
Verify the change with:
java -version
Many Java applications require the JAVA_HOME environment variable.
Open the environment configuration file:
sudo nano /etc/environment
Add your Java installation path:
JAVA_HOME="/usr/lib/jvm/java-25-openjdk-amd64"
Apply the changes:
source /etc/environment
Confirm the variable is working:
echo $JAVA_HOME
Learning how to install Java Ubuntu systems properly helps developers avoid compatibility issues and simplifies project setup. OpenJDK remains the best option for most users, while Oracle JDK is useful for enterprise workloads and vendor-supported deployments.
Ubuntu 24.04 makes Java management straightforward with flexible installation methods, version switching tools, and easy environment configuration.
Ubuntu users often download software directly from developer websites instead of using the default app…
Installing Ubuntu 26.04 LTS is only the first step toward building a smooth, secure, and…
What is a Software Supply Chain Attack? A software supply chain attack occurs when a…
When people ask how UDP works, the simplest answer is this: UDP sends data quickly…
Endpoint Detection and Response (EDR) solutions have become a cornerstone of modern cybersecurity, designed to…
A large-scale malware campaign leveraging AI-assisted development techniques has been uncovered, revealing how attackers are…