If you’re using a Debian-based system (such as Debian 10, 11, or 12 or Ubuntu 22.04 or 24.04) and need to install the latest Java Development Kit (JDK 23), this guide will walk you through the process step by step.
Installing Java 23 on Debian
To install JDK 23 on your Debian-based system, follow these instructions carefully.
Step 1: Download the JDK 23 Package
Oracle provides the latest Java Development Kit (JDK) as a .deb
package. Use the wget
command to download it directly from the official Oracle website:
wget https://download.oracle.com/java/23/latest/jdk-23_linux-x64_bin.deb
Step 2: Install the JDK 23 Package
Once the download is complete, install the package using the dpkg
command:
sudo dpkg -i jdk-23_linux-x64_bin.deb
If you encounter dependency errors, resolve them by running:
sudo apt-get -f install
Step 3: Clean Up the Installation Files
After installation, you can remove the downloaded .deb
package to free up space:
rm jdk-23_linux-x64_bin.deb
Step 4: Verify the Installation
Check if Java is installed correctly by running:
java -version
Expected output (version may vary):
java version "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)
If you see output similar to this, your JDK 23 installation is successful, and you’re ready to start developing Java applications.
Managing Multiple Java Versions on Debian
If you have multiple versions of Java installed (e.g., Java 11, 12, 13, and 23), you may need to switch between them depending on project requirements. Debian allows you to manage Java versions easily using update-alternatives
.
Step 1: Check Installed Java Versions
To see a list of all installed Java versions, run:
sudo update-alternatives --config java
Example output:
There are 8 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/jdk-23.0.2-oracle-x64/bin/java 385892352 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
2 /usr/lib/jvm/java-15-openjdk-amd64/bin/java 1511 manual mode
3 /usr/lib/jvm/java-17-openjdk-amd64/bin/java 1711 manual mode
4 /usr/lib/jvm/java-18-openjdk-amd64/bin/java 1811 manual mode
5 /usr/lib/jvm/java-19-openjdk-amd64/bin/java 1911 manual mode
6 /usr/lib/jvm/java-21-openjdk-amd64/bin/java 2111 manual mode
7 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
* 8 /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:
Step 2: Switch to Java 23
To switch to Java 23, enter the corresponding selection number (e.g., 3
in this example):
sudo update-alternatives --config java
Select the desired version and press Enter
. In my case it was 8.
Step 3: Verify the Change
After switching versions, verify that the correct Java version is active:
java -version
Expected output:
java version "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)
Switching the Java Compiler (javac)
If you also need to switch the Java compiler (javac
), use:
sudo update-alternatives --config javac
This allows you to manage multiple Java versions efficiently, ensuring you use the right one for your projects.
There are 8 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/jdk-23.0.2-oracle-x64/bin/javac 385892352 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/javac 1101 manual mode
2 /usr/lib/jvm/java-15-openjdk-amd64/bin/javac 1511 manual mode
3 /usr/lib/jvm/java-17-openjdk-amd64/bin/javac 1711 manual mode
4 /usr/lib/jvm/java-18-openjdk-amd64/bin/javac 1811 manual mode
5 /usr/lib/jvm/java-19-openjdk-amd64/bin/javac 1911 manual mode
6 /usr/lib/jvm/java-21-openjdk-amd64/bin/javac 2111 manual mode
7 /usr/lib/jvm/java-8-openjdk-amd64/bin/javac 1081 manual mode
* 8 /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:
You can also check your JAVA_HOME to ensure everything is in order:
echo $JAVA_HOME
#Output should be: /usr/lib/jvm/jdk-23.0.2-oracle-x64
Conclusion
You have now successfully installed Java 23 on your Debian-based system and learned how to switch between different Java versions. This setup gives you flexibility when working on multiple Java projects that require different environments.
Start coding with the latest Java tools and enjoy enhanced performance and new features!
- Roblox Force Trello - February 25, 2025
- 20 Best Unblocked Games in 2025 - February 25, 2025
- How to Use Java Records to Model Immutable Data - February 20, 2025