SlideShare a Scribd company logo
1/7
May 10, 2025
How to Install Java on Debian 12: Using Apt and Deb
greenwebpage.com/community/how-to-install-java-on-debian-12/
Tutorials
by Karim Buzdar
May 10, 2025
Java is an open-source programming language that is recognized worldwide for its use in
developing web applications, mobile applications, and even games. Java is well-known
for its robust features including being object-oriented, security, scalability, and others.
Furthermore, Java is known for its multi-platform functionality and can be installed and
used on several Operating systems, such as Linux, Windows, and Mac OS.
Debian 12 represents the fan’s latest release and can be downloaded from Debian’s
official page. We can install Java on Debian 12 and take advantage of these features. For
this reason, several package managers such as apt, .deb and others can be used.
How to Install Java on Debian 12
Installation of Java on Debian 12 can be done using the “Apt” package manager and
“Deb” package. For now, we will focus on the apt package manager as the point of
starting.
Method 1: Installing Java on Debian 12 Using Apt
2/7
Java may be installed on Debian 12 using either JDK or JRE. Apt is an easy command-
line utility for installing default or specific versions of Java. Although JDK and JRE have
the same purpose for running Java programs, it is recommended that you install JDK on
Debian because it offers additional functionalities for both executing and developing Java
software.
For Java installation using Apt on Debian 12, follow the simple steps outlined below:
Step 1: Update and Upgrade System Repositories
In order to install Java, the command below needs to be executed first in order to update
and upgrade the repository.
sudo apt update && sudo apt upgrade
Next, any outdated packages are scanned. As the repositories are updated and upgraded
on the system, we can now proceed to step two.
Step 2: Check Available Java Versions
To list all the available versions of Java that can be installed on the system, run the
command below:
javac –version
The snippet of output indicates that Java is not installed on my machine but still presents
a range of versions that can be added.
You can select the Java version that you need and run the respective command that will
configure it on your computer.
Step 3: Install Java Using Apt
Choose the version of Java you would like to install from the available options and run the
command below to install it on your Debian 12:
sudo apt install default-jdk -y
3/7
The command prompt shows that the JDK is installed, which will also be reflected on the
default screenshot.
Below is an example of how you can change “default-jdk” to any specific version to install
other versions.
sudo apt install java_version
Step 4: Verify Java Installation
To check that Java is installed on your Debian 12 machine, use the command below that
checks which version is available on your system.
java –version
The result indicates that our Debian 12 now has “openjdk 21.0.3” Java installed.
Method 2: Installing Java on Debian 12 Using Deb
We can utilize the command wget for downloading the deb package of Java and use the
apt command for its installation. To make things simple, follow the sequential steps listed
below:
Step 1: Download the Deb Package
4/7
Wget is a CLI tool that downloads documents from the internet. Run the command below
in the terminal to get the Java deb package from the Oracle Website:
sudo wget https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.deb
Step 2: Install Java Using Deb
After that, utilize the below command line for installing Java through the deb package.
sudo apt install ./jdk-21_linux-x64_bin.deb
Step 3: Confirm Java Installation
Now, you can enter the command required to check that Java has been installed on
Debian 12.
java –version
5/7
Switching Default Java Version on Debian 12
In case one is running multiple Java versions, one can change them with the specified
command.
sudo update-alternatives –config java
One can either press “Enter” to keep the default Java version as is or change one by
entering a selection number corresponding to the desired version.
Setting JAVA_HOME Environment Variable on Debian 12
If you wish to change the JAVA_HOME path variable on Debian, you may do so by editing
the /etc/environment file using nano. You can open it by entering the command below.
sudo nano /etc/environment
Then, as seen in the example below, change the variable definition in the file to the path
for the chosen version of Java you would like to use.
JAVA_HOME=”/usr/lib/jvm/java-21-openjdk-amd64/bin/java”
6/7
In the nano editor, hit “CTRL+S” as well as “CTRL+X” to save the line and exit the
interface.
To apply the newly defined JAVA_HOME variable for the active session, use the
command below to reload the /etc/environment file.
source /etc/environment
Run the command below to check if the JAVA_HOME variable is properly defined.
echo $JAVA_HOME
How to Uninstall Java From Debian 12
In the event that Java is deemed unnecessary, one can remove it to recover hard drive
space. In any case, the manner in which Java is installed determines how it can be
uninstalled.
Method 1: Uninstalling Java From Debian 12 Using Apt
If Java was added via Apt, it can also be removed from Debian 12 using the following
command:
7/7
sudo apt autoremove java* -y
Method 2: Uninstalling Java From Debian 12 Using Deb
If Java is installed on Debian using the deb package, it can be removed by executing:
sudo apt autoremove jdk-21 -y
This sums up the installation and uninstallation of Java on Debian 12.
Final Thoughts
Using both “apt” and “deb”, Java can be installed on Debian 12. As noted, all methods
allow the installation of Java on Debian 12. Still, each installation technique comes with
advantages and disadvantages. For example, once Java is added through apt or deb,
multiple versions can be interchanged swiftly. This guide has covered all possible
methods to install Java on Debian 12.
© 2023 Greenwebpage.com Community All Rights Reserved by

More Related Content

PDF
How to Install OpenJDK on Debian 12 Server.pdf
PDF
How to Install JAVA 7 (JDK 7u79) on CentOS_RHEL 7_6_5
PPTX
Jdk installation
PDF
Usage Note of Apache Thrift for C++ Java PHP Languages
PDF
How to Install Python on Debian 12 Server
DOCX
JAVA CORE
PDF
How to Upgrade Linux Mint From 21 to 22.pdf
PDF
How to Install VirtualBox on Linux Mint 22.pdf
How to Install OpenJDK on Debian 12 Server.pdf
How to Install JAVA 7 (JDK 7u79) on CentOS_RHEL 7_6_5
Jdk installation
Usage Note of Apache Thrift for C++ Java PHP Languages
How to Install Python on Debian 12 Server
JAVA CORE
How to Upgrade Linux Mint From 21 to 22.pdf
How to Install VirtualBox on Linux Mint 22.pdf

More from Green Webpage (20)

PDF
How to Install VMware Workstation on Linux Mint 22.pdf
PDF
How to Install Google Chrome on Ubuntu 24.04.pdf
PDF
How to Install XRDP on Debian 12 Server.pdf
PDF
How to Install Apache on Debian 12 Server
PDF
How to Install Cuda on Debian 12 Server.pdf
PDF
How to Install GCC Compiler on Debian 12.pdf
PDF
How to Install UFW Firewall on Debian 12.pdf
PDF
How to Check the Kernel Version in Debian 12.pdf
PDF
How to Install and Configure MariaDB on Debian 12.pdf
PDF
How to Install phpMyAdmin on Debian 12.pdf
PDF
How to Install and Configure Webmin on Debian 12.pdf
PDF
How to Change an IP Address on Debian 12.pdf
PDF
How to Install Plex Media Server on Debian 12.pdf
PDF
How to Install KVM (Kernel-based Virtual Machine) on Debian 12
PDF
How to Install Nextcloud on Debian 12.pdf
PDF
How to Install VNC Server on Debian 12.pdf
PDF
How to Install Portainer Docker UI Web Interface on Debian 12.pdf
DOCX
How to Install iptable on Debian 12.docx
DOCX
How to Install Proxmox on Debian 12_ .docx
PDF
How to Install MySQL on Debian 12 In Just 8 Steps.pdf
How to Install VMware Workstation on Linux Mint 22.pdf
How to Install Google Chrome on Ubuntu 24.04.pdf
How to Install XRDP on Debian 12 Server.pdf
How to Install Apache on Debian 12 Server
How to Install Cuda on Debian 12 Server.pdf
How to Install GCC Compiler on Debian 12.pdf
How to Install UFW Firewall on Debian 12.pdf
How to Check the Kernel Version in Debian 12.pdf
How to Install and Configure MariaDB on Debian 12.pdf
How to Install phpMyAdmin on Debian 12.pdf
How to Install and Configure Webmin on Debian 12.pdf
How to Change an IP Address on Debian 12.pdf
How to Install Plex Media Server on Debian 12.pdf
How to Install KVM (Kernel-based Virtual Machine) on Debian 12
How to Install Nextcloud on Debian 12.pdf
How to Install VNC Server on Debian 12.pdf
How to Install Portainer Docker UI Web Interface on Debian 12.pdf
How to Install iptable on Debian 12.docx
How to Install Proxmox on Debian 12_ .docx
How to Install MySQL on Debian 12 In Just 8 Steps.pdf
Ad

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Approach and Philosophy of On baking technology
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Big Data Technologies - Introduction.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
cuic standard and advanced reporting.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Programs and apps: productivity, graphics, security and other tools
Building Integrated photovoltaic BIPV_UPV.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Spectral efficient network and resource selection model in 5G networks
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
MYSQL Presentation for SQL database connectivity
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Diabetes mellitus diagnosis method based random forest with bat algorithm
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Approach and Philosophy of On baking technology
Understanding_Digital_Forensics_Presentation.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Big Data Technologies - Introduction.pptx
Review of recent advances in non-invasive hemoglobin estimation
Chapter 3 Spatial Domain Image Processing.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
The AUB Centre for AI in Media Proposal.docx
cuic standard and advanced reporting.pdf
Empathic Computing: Creating Shared Understanding
Programs and apps: productivity, graphics, security and other tools
Ad

How to Install Java on Debian 12 Using Apt and Deb.pdf

  • 1. 1/7 May 10, 2025 How to Install Java on Debian 12: Using Apt and Deb greenwebpage.com/community/how-to-install-java-on-debian-12/ Tutorials by Karim Buzdar May 10, 2025 Java is an open-source programming language that is recognized worldwide for its use in developing web applications, mobile applications, and even games. Java is well-known for its robust features including being object-oriented, security, scalability, and others. Furthermore, Java is known for its multi-platform functionality and can be installed and used on several Operating systems, such as Linux, Windows, and Mac OS. Debian 12 represents the fan’s latest release and can be downloaded from Debian’s official page. We can install Java on Debian 12 and take advantage of these features. For this reason, several package managers such as apt, .deb and others can be used. How to Install Java on Debian 12 Installation of Java on Debian 12 can be done using the “Apt” package manager and “Deb” package. For now, we will focus on the apt package manager as the point of starting. Method 1: Installing Java on Debian 12 Using Apt
  • 2. 2/7 Java may be installed on Debian 12 using either JDK or JRE. Apt is an easy command- line utility for installing default or specific versions of Java. Although JDK and JRE have the same purpose for running Java programs, it is recommended that you install JDK on Debian because it offers additional functionalities for both executing and developing Java software. For Java installation using Apt on Debian 12, follow the simple steps outlined below: Step 1: Update and Upgrade System Repositories In order to install Java, the command below needs to be executed first in order to update and upgrade the repository. sudo apt update && sudo apt upgrade Next, any outdated packages are scanned. As the repositories are updated and upgraded on the system, we can now proceed to step two. Step 2: Check Available Java Versions To list all the available versions of Java that can be installed on the system, run the command below: javac –version The snippet of output indicates that Java is not installed on my machine but still presents a range of versions that can be added. You can select the Java version that you need and run the respective command that will configure it on your computer. Step 3: Install Java Using Apt Choose the version of Java you would like to install from the available options and run the command below to install it on your Debian 12: sudo apt install default-jdk -y
  • 3. 3/7 The command prompt shows that the JDK is installed, which will also be reflected on the default screenshot. Below is an example of how you can change “default-jdk” to any specific version to install other versions. sudo apt install java_version Step 4: Verify Java Installation To check that Java is installed on your Debian 12 machine, use the command below that checks which version is available on your system. java –version The result indicates that our Debian 12 now has “openjdk 21.0.3” Java installed. Method 2: Installing Java on Debian 12 Using Deb We can utilize the command wget for downloading the deb package of Java and use the apt command for its installation. To make things simple, follow the sequential steps listed below: Step 1: Download the Deb Package
  • 4. 4/7 Wget is a CLI tool that downloads documents from the internet. Run the command below in the terminal to get the Java deb package from the Oracle Website: sudo wget https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.deb Step 2: Install Java Using Deb After that, utilize the below command line for installing Java through the deb package. sudo apt install ./jdk-21_linux-x64_bin.deb Step 3: Confirm Java Installation Now, you can enter the command required to check that Java has been installed on Debian 12. java –version
  • 5. 5/7 Switching Default Java Version on Debian 12 In case one is running multiple Java versions, one can change them with the specified command. sudo update-alternatives –config java One can either press “Enter” to keep the default Java version as is or change one by entering a selection number corresponding to the desired version. Setting JAVA_HOME Environment Variable on Debian 12 If you wish to change the JAVA_HOME path variable on Debian, you may do so by editing the /etc/environment file using nano. You can open it by entering the command below. sudo nano /etc/environment Then, as seen in the example below, change the variable definition in the file to the path for the chosen version of Java you would like to use. JAVA_HOME=”/usr/lib/jvm/java-21-openjdk-amd64/bin/java”
  • 6. 6/7 In the nano editor, hit “CTRL+S” as well as “CTRL+X” to save the line and exit the interface. To apply the newly defined JAVA_HOME variable for the active session, use the command below to reload the /etc/environment file. source /etc/environment Run the command below to check if the JAVA_HOME variable is properly defined. echo $JAVA_HOME How to Uninstall Java From Debian 12 In the event that Java is deemed unnecessary, one can remove it to recover hard drive space. In any case, the manner in which Java is installed determines how it can be uninstalled. Method 1: Uninstalling Java From Debian 12 Using Apt If Java was added via Apt, it can also be removed from Debian 12 using the following command:
  • 7. 7/7 sudo apt autoremove java* -y Method 2: Uninstalling Java From Debian 12 Using Deb If Java is installed on Debian using the deb package, it can be removed by executing: sudo apt autoremove jdk-21 -y This sums up the installation and uninstallation of Java on Debian 12. Final Thoughts Using both “apt” and “deb”, Java can be installed on Debian 12. As noted, all methods allow the installation of Java on Debian 12. Still, each installation technique comes with advantages and disadvantages. For example, once Java is added through apt or deb, multiple versions can be interchanged swiftly. This guide has covered all possible methods to install Java on Debian 12. © 2023 Greenwebpage.com Community All Rights Reserved by