Java is one of the most popular programming languages, powering enterprise systems, cloud applications, and Android development. On Ubuntu 24.04.3 LTS, you can easily install OpenJDK 11, which is a Long-Term Support (LTS) version and widely used in production environments.
Here, you’ll learn:
1. What OpenJDK 11 is and why to use it
2. Step-by-step installation on Ubuntu 24.04.3
3. How to verify your Java installation
4. How to set up environment variables (JAVA_HOME and PATH)
1. What is OpenJDK 11?
OpenJDK (Open Java Development Kit) is the official open-source implementation of Java SE (Standard Edition).
- OpenJDK 11 was first released in September 2018.
- It is a Long-Term Support (LTS) release, making it a stable choice for enterprises and developers.
- It provides tools such as the Java Runtime Environment (JRE) and Java Compiler (javac).
2. Step 1: Update Your System
Step 2: Install OpenJDK 11
Ubuntu’s repositories include OpenJDK 11. To install it, run:
sudo apt install openjdk-11-jdk
This installs both the JDK (Java Development Kit) and the JRE (Java Runtime Environment).
3. How to verify your Java installation
Check the installed Java version:
java -version
You should see output similar to:
openjdk version "11.0.28" 2025-07-15
OpenJDK Runtime Environment (build 11.0.28+6-post-Ubuntu-1ubuntu124.04.1)
To check the compiler:
javac -version
4. How to set up environment variables (JAVA_HOME and PATH)
Some applications (e.g., Tomcat, Maven, Gradle) require JAVA_HOME to be set.
a) Find the Installation Path
sudo update-alternatives --config java
You’ll see something like:
Selection Path Priority Status
------------------------------------------------------------------------------------------------
* 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
The Java home directory is:
/usr/lib/jvm/java-11-openjdk-amd64
b) Edit Your Profile
sudo vi /etc/profile
Add these lines at the bottom:
# Java Environment Variables
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
c) Apply Changes
Saving and exiting using following command.
:wq
d) Verify
echo $JAVA_HOME
Output should be:
/usr/lib/jvm/java-11-openjdk-amd64