Step 1: Update Your System
Before we begin, it’s crucial to ensure that your system is up-to-date. This can be done by running the following commands:
sudo apt-get update
sudo apt-get dist-upgrade -y
The apt-get update command fetches the package lists from the repositories and updates them to get information about the newest versions of packages and their dependencies.
The apt-get dist-upgrade command is used to handle changing dependencies with new versions of packages. It will intelligently handle the dependencies, so it might remove obsolete packages or add new ones.
After updating, it’s a good practice to remove unnecessary packages. This can be done by running:
sudo apt autoremove -y
The apt autoremove command is used to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.
Finally, reboot your system to ensure all updates are correctly applied:
reboot
Step 2: Download Java 1.8 Packages
Next, we’ll create a directory to store our Java packages and navigate into it:
mkdir /root/java
cd /root/java
Now, we’ll download the necessary Java 1.8 packages from the Debian snapshot archive:
wget http://snapshot.debian.org/archive/debian-security/20220210T090326Z/pool/updates/main/o/openjdk-8/openjdk-8-jdk_8u322-b06-1~deb9u1_amd64.deb
wget http://snapshot.debian.org/archive/debian-security/20220210T090326Z/pool/updates/main/o/openjdk-8/openjdk-8-jdk-headless_8u322-b06-1~deb9u1_amd64.deb
wget http://snapshot.debian.org/archive/debian-security/20220210T090326Z/pool/updates/main/o/openjdk-8/openjdk-8-jre_8u322-b06-1~deb9u1_amd64.deb
wget http://snapshot.debian.org/archive/debian-security/20220210T090326Z/pool/updates/main/o/openjdk-8/openjdk-8-jre-headless_8u322-b06-1~deb9u1_amd64.deb
The wget command is a free utility for non-interactive download of files from the web. It supports HTTP, HTTPS, and FTP protocols, and can retrieve files through HTTP proxies.
Step 3: Install Java 1.8 Packages
After downloading the packages, we can install them using the dpkg command:
dpkg -i *.deb
The dpkg -i command is used to install a package. The *.deb is a wildcard that matches all .deb files in the current directory.
Finally, we’ll ensure that any missing dependencies are fixed:
apt install -f
The apt install -f command is a handy way to fix broken dependencies.
And that’s it! You’ve successfully installed Java 1.8 on your Debian 12 system.