How to Install Oracle Java (JDK) on Ubuntu 24.04 LTS & Debian Linux

Опубликовано: 14 Март 2026
на канале: English Technology
147
4

How to Install Oracle Java (JDK) on Ubuntu 24.04 LTS & Debian Linux

For developers who require the most recent Java features and performance improvements, installing the Oracle Java Development Kit (JDK) on Ubuntu 24.04 LTS or Debian Linux may be crucial. You can follow this tutorial to download and install Oracle JDK on your computer. To get Java up and running, follow these instructions.

🎯 Detailed Instructions:-

📌 Step 1: Download the Oracle JDK:-

1. Access the [Oracle JDK Downloads page](https://www.oracle.com/java/technolog..., by opening your web browser.
2. Locate the JDK section and choose the Linux x64.deb file that corresponds to your system.
3. Download the deb file to your computer after accepting the Oracle license agreement.

📌 Step 2: Launch the Terminal:-

1. To open a terminal window, press `Ctrl + Alt + T` or look for "Terminal" in the Applications menu.

📌 Step 3: Installing dependencies:-

1. Run the following command to make sure your package list is current before installing the JDK:
``bash
sudo apt update
``

📌 Step 4: Installing JDK:-

1. Open the directory in which the deb file was downloaded. For instance, use ```bash cd ~/Downloads ~`` if the file is in your Downloads folder.
2. Use the `dpkg` command to install the.deb package: ```bash sudo dpkg -i jdk-22_linux-x64_bin.deb ```
3. Run the following command to fix any dependency problems you may be having:
``bash sudo apt-get install -f ```

📌 Step 5: Verify the installation:-

1. Verify the Java version to make sure the JDK was installed correctly:
``bashjava -version
``
The output should show that Java 22 has been installed.

You can also verify the JDK installation path: ```bash which java ```

📌 Step 6: Configure the Environment Variable for Java Home:-

1. For many development tools, it is essential to set the JAVA_HOME environment variable. Launch a text editor and open your `.bashrc` file: ```bash nano ~/.bashrc ```
2. At the end of the file, add the following lines, substituting the path with the actual path where JDK is installed: ```bash export JAVA_HOME=/usr/lib/jvm/jdk-22 {`` PATH=$PATH:$JAVA_HOME/bin
3. Press `Ctrl + X`, `Y`, and `Enter` to save the file and close the text editor (in Nano).
4.Sourcethe`.bashrc`file to apply the modifications:
```bash source~/.bashrc

📌 Step 7: Check for Java Home:-

1. Run:
``bash echo $JAVA_HOME ``` to verify that the JAVA_HOME environment variable is set correctly.
The path to your JDK installation should be output by this.

🎯 Extra Advice:-

**Updating JDK**: Use the same procedures to download and install the latest deb package whenever a new version of JDK is made available.
**Changing Versions of Java**: Use `update-alternatives` if you need to keep track of several Java versions:
```bash suo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-22/bin/java 1 suo update-alternatives --config java
```

You can use the newest Java features for your development projects by successfully installing Oracle JDK on your Ubuntu 24.04 LTS or Debian Linux system by following these steps.

Remember to subscribe, like, and share for more tech tips and tutorials!

#OracleJDK #javadevelopment #ubuntu2404 #DebianLinux #linuxtutorial
#openjdk #javaprogramming #devops #softwaredevelopment #techguide