This guide will teach you how to install and configure JDK 8 on Kali Linux. Java 8 is a very helpful platform that can be used in several hacking projects. Java 8 isn’t available in the kali Linux repository by default, and while installing it, you may get an APK signing failed error because Openjdk-8 isn’t installed on your kali Linux.
Install OpenJDK 8
We can install Java 8 in Kali Linux manually, but before that, we must install OpenJDK 8’s Debian Package. Visit Oracle’s official website and register to download the package to your system. Click on the Linux tab and download the required package. We’ll download the Debian package (x64 Compressed Archive) for this guide.
Now open the terminal window on your PC. First, check which version of java is already installed on your system by using this command:
You will see OpenJDK 11, a default version installed in Kali Linux. Now navigate into the JVM directory using this command:
If you haven’t installed any java package already, you can create the above directory using the following command.
Now within this directory, extract the OpenJDK 8 using this command:
sudo tar -xvzf ~/Downloads/jdk-8u321-linux-x64.tar.gz
“~/Downloads/jdk-8u321-linux-x64.tar.gz” is the path and the name of the downloaded Java package on my system. After that, enter the password for the system user and then this compressed file will be extracted to this JVM folder.
Once the extraction process completes, a new folder named jdk1.8.0 will be created.
Now you can set the path for the java file by changing the environment variable. You’ll get the environment variable file inside the ‘etc’ folder, and you can open it in any text editor to set the path according to your requirement. Use the following command to edit the environment variable file to modify the path variable.
sudo gedit /etc/environment
You will find a path variable and several path sets already assigned to it in the environment file. You can open the Environment variable file in any text editor.
If you want to add/assign any new path to it, append a colon and paste the path. So, here we have added the OpenJDK 8’s bin folder path inside which all java files reside. After setting all the paths, save and close this file.
Now install the OpenJDK 8 as an alternative to the OpenJDK 11 and select the java version according to your needs. Use the following command to install the OpenJDK 8.
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_321/bin/java" 0
The paths in the above command may vary depending on the paths in your environment file. To set the java compiler for this file, add c at the end of the path in the same command.
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_321/bin/javac" 0
After installation, you can select any available java version you wish using the following command:
sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_321/bin/java
“/usr/lib/jvm/jdk1.8.0_321/bin/java” is the path of the java version we selected. Now this version will be set as the default version. In the same way, we can select the Java compiler version using the following command:
sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_321/bin/javac
Now you can choose to use OpenJDK 8 or 11 according to your needs by using this command:
sudo update-alternatives --config java
You will get a list of available java versions.
To select a version from the list, you need to enter the associated digit; for example, if you want to work with java 8, press the number 2 to set it to default. It will automatically start using java 8.
To verify whether the selected version is running, use the following command on the terminal.
So, following this comprehensive guide, we can manually install OpenJDK 8 on the Kali Linux Machine.