How To Install Oracle Java (JDK) On Ubuntu 24.04 LTS, Debian Linux (2024)

preview_player
Показать описание
How to Install Oracle Java (JDK) on Ubuntu 24.04 LTS / Debian Linux | Step-by-Step Guide | Setting JAVA_HOME
Installing Oracle Java Development Kit (JDK) on Ubuntu 24.04 LTS or Debian Linux can be essential for developers needing the latest Java features and performance enhancements. This guide will walk you through the process of downloading and installing Oracle JDK on your system. Follow these steps to get Java up and running.

**Step-by-Step Instructions:**

**Step 1: Download Oracle JDK **

2. Find the section for JDK and select the appropriate package for your system (Linux x64 .deb file).
3. Accept the Oracle license agreement and download the .deb file to your computer.

**Step 2: Open Terminal**

1. Press `Ctrl + Alt + T` or search for "Terminal" in the Applications menu to open a terminal window.

**Step 3: Install Dependencies**

1. Before installing the JDK, ensure that your package list is up to date by running:
```bash
sudo apt update
```

**Step 4: Install JDK **

1. Navigate to the directory where you downloaded the .deb file. For example, if the file is in your Downloads folder, use:
```bash
cd ~/Downloads
```
2. Install the .deb package using the `dpkg` command:
```bash
```
3. If you encounter any dependency issues, resolve them by running:
```bash
sudo apt-get install -f
```

**Step 5: Verify the Installation**

1. To ensure that the JDK was installed correctly, check the Java version:
```bash
java -version
```
You should see output indicating that Java 22 is installed.

2. Additionally, you can check the JDK installation path:
```bash
which java
```

**Step 6: Set Up JAVA_HOME Environment Variable**

1. Setting the JAVA_HOME environment variable is crucial for many development tools. Open your `.bashrc` file in a text editor:
```bash
nano ~/.bashrc
```
2. Add the following lines at the end of the file, replacing the path with the actual path where JDK is installed:
```bash
export JAVA_HOME=/usr/lib/jvm/jdk-22
export PATH=$PATH:$JAVA_HOME/bin
```
3. Save the file and exit the text editor (in Nano, press `Ctrl + X`, then `Y`, and `Enter`).
4. Apply the changes by sourcing the `.bashrc` file:
```bash
source ~/.bashrc
```

**Step 7: Verify JAVA_HOME**

1. To confirm that the JAVA_HOME environment variable is set correctly, run:
```bash
echo $JAVA_HOME
```
This should output the path to your JDK installation.

**Additional Tips:**

- **Updating JDK**: When a new version of JDK is released, you can download and install the new .deb package following the same steps.
- **Switching Between Java Versions**: If you need to manage multiple Java versions, consider using `update-alternatives`:
```bash
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-22/bin/java 1
sudo update-alternatives --config java
```

By following these steps, you can successfully install Oracle JDK on your Ubuntu 24.04 LTS or Debian Linux system, enabling you to leverage the latest Java features for your development projects.

Don't forget to like, share, and subscribe for more tech tutorials and tips!

#OracleJDK #Java22 #Ubuntu #Debian #Linux #Ubuntu2404LTS #TechTutorial #HowTo #JavaDevelopment #OpenSource #TechTips #Tutorial

#JavaInstallation #OracleJDK #Ubuntu2204LTS #DebianLinux #JavaDevelopment #JavaProgramming #LinuxTutorials #StepByStepGuide
JavaJDK#Javatutorialforbeginners #Javatutorial #Javaprogramming #Javaprogrammingtutorial #Javabasicsforbeginners #Ubuntu #Debian #Linux
Рекомендации по теме
Комментарии
Автор

Thanks a lot bro! You really helped me! I've just installed ubuntu 24.04 and needed to set my Java variables! Tks a lot

gabrielmalheiro
Автор

thanks man, very easy and worked very well

ashunegi
Автор

Excelente, mucha gracias, de vrdad muy bien explicado, me encantó

cscasill
Автор

Very rich content!! I suscribe to ur channel dude!

quesomagro
Автор

Muito bem explicado, o melhor até agora!

camilaklitzkecorrea
Автор

thank you! can i start making java project now or i need to setup something else ?

danta.
Автор

Bhai in Ubuntu I can't set up in C language Vs Code and can't run it so u can help me bro 😢

Riteshraaz
Автор

could not open
Plz solve this error sir

Comedywithai