Skip to content
Follow
Ubuntu Linux

How to Install Oracle JDK on Ubuntu 24.04

Richard
Written by
Richard
Mar 11, 2025 Updated Sep 15, 2026 3 min read
How to Install Oracle JDK on Ubuntu 24.04
How to Install Oracle JDK on Ubuntu 24.04

Installing Oracle JDK on Ubuntu 24.04 gives you the official software toolkit you need to build and run Java programs on your computer. Oracle JDK contains the Java Runtime Environment (a package that runs Java apps) and the tools required to write and compile code.

Advertisement

This process sets up Oracle JDK 21, the current long-term support release. You need an Ubuntu machine with administrator rights to complete these steps.

⚡ Quick Answer

Install Oracle JDK by downloading the .deb package and running `sudo apt install ./jdk-XX_linux-x64_bin.deb`. Then, configure your environment by sourcing `/etc/profile.d/java.sh`. Verify the installation with `java –version`.

Advertisement

Install Oracle JDK

You can install Oracle JDK on Ubuntu 24.04 by downloading the latest Java SE Development Kit package directly from the Oracle website and running a few commands in your terminal. Make sure to note your specific version number during this process so you can set up the file paths correctly.

Download the latest  Java SE Development Kit 23 release.

⚠️WarningNote the version number you are downloading.

If a newer version number is available, choose that one instead.

You can install the Java DEB package by executing the commands below. As of this writing, the latest version of the Java JDK is 23.

Advertisement
⬛Command Prompt
cd /tmp
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/java/23/latest/jdk-23_linux-x64_bin.deb"

Once you have downloaded the correct archive package for your system, run the commands below to install Oracle Java.

Again, the current latest version is jdk-23

🐧Bash / Shell
sudo apt install ./jdk-23_linux-x64_bin.deb

After installing all the packages, run the command below to configure Ubuntu so that Oracle JDK can function properly, including setting the JAVA_HOME variable and the environment PATH.

🐧Bash / Shell
sudo tee -a /etc/profile.d/java.sh <<'EOF'
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))))
export PATH=$PATH:$JAVA_HOME/bin
EOF

Activate the script by running the command below.

Advertisement
🐧Bash / Shell
sudo -s
source /etc/profile.d/java.sh

Test Oracle JDK

You can test Oracle JDK on Ubuntu to confirm the installation worked by opening your terminal and running a quick version check command. Type java --version and press Enter to see your installed build details and verify the system recognizes the software.

💻Code
java --version

It should output similar lines shown below.

💻Code
java 23.0.2 2025-01-21
Java(TM) SE Runtime Environment (build 23.0.2+7-58)
Java HotSpot(TM) 64-Bit Server VM (build 23.0.2+7-58, mixed mode, sharing)

Oracle JDK is installed and ready to use.

Choose the default

You can choose the default Java version on Ubuntu when multiple releases are installed by running the update alternatives tool in your terminal. This command lets you view a numbered list of all available Java builds on your system and pick your preferred default.

Advertisement
🐧Bash / Shell
sudo update-alternatives --config java

Select the Java version you wish to use as the default.

💻Code
  Selection    Path                                         Priority   Status
------------------------------------------------------------
* 0 /usr/lib/jvm/jdk-23.0.2-oracle-x64/bin/java 385892352 auto mode
1 /usr/lib/jvm/jdk-23.0.2-oracle-x64/bin/java 385892352 manual mode

Press <enter> to keep the current choice[*], or type selection number:
💡TipAlso run the command below to choose the default javac version.
🐧Bash / Shell
sudo update-alternatives --config javac

Choose the javac version you want to set as default.

💻Code
  Selection    Path                                          Priority   Status
------------------------------------------------------------
* 0 /usr/lib/jvm/jdk-23.0.2-oracle-x64/bin/javac 385892352 auto mode
1 /usr/lib/jvm/jdk-23.0.2-oracle-x64/bin/javac 385892352 manual mode

Press <enter> to keep the current choice[*], or type selection number:

That should do it!

Conclusion:

  • Installing Oracle JDK on Ubuntu allows developers to leverage a robust and high-performance environment for Java application development.
  • Following the outlined steps ensures a proper setup, including the Java Home and Path configurations.
  • Testing the installation with the java --version command verifies that Oracle JDK is running correctly.
  • The update-alternatives command simplifies managing multiple JDK installations, allowing easy selection of the desired version.
  • With Oracle JDK successfully installed and configured, you can start developing Java applications efficiently.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

📚 Related Tutorials

How to Install Oracle Java JDK on Windows 11
Windows How to Install Oracle Java JDK on Windows 11
How to Install GNOME Desktop on Ubuntu 24.04
Ubuntu Linux How to Install GNOME Desktop on Ubuntu 24.04
How to Install KDE Desktop on Ubuntu 24.04
Ubuntu Linux How to Install KDE Desktop on Ubuntu 24.04
How to List Services on Ubuntu Linux
Ubuntu Linux How to List Services on Ubuntu Linux

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *