How to install Java on Kali Linux

The objective of this guide is to show how to install the Java Development Kit (JDK) on Kali Linux. This is needed by Java developers and programmers in order to compile and run Java applications. It’s also required for security tools that are built in Java.

In this tutorial you will learn:

  • How to install Java JDK in Kali Linux

Installing Java JDK via command line on Kali Linux

Installing Java JDK via command line on Kali Linux

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Kali Linux
Software Java JDK
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Install Java JDK on Kali

Open a command line terminal and follow the steps below to install Java. We’ll test the installation afterwards by checking the Java version and compiling a test program.

  1. Use the apt package manager to update your system’s repositories and install the default JDK package.
    $ sudo apt update
    $ sudo apt install default-jdk
    

    If you want to install a specific version of the JDK, use the following command to search for the exact package you want. This will show all the JDK packages available for installation.

    $ sudo apt-cache search openjdk
    


  2. Once the process is finished, you can verify the Java installation with the following command.
    $ java --version
    
  3. For further verification that you can compile and run Java programs, try compiling a Java Hello World program.
  4. To switch between Java versions, execute the following two commands while selecting the Java version you require.
    $ sudo update-alternatives --config java
    $ sudo update-alternatives --config javac
    

Closing Thoughts

In this guide, we saw how to install Java JDK on Kali Linux. We also saw how to test the installation with a Java command and Hello World program, as well as the process for switching between installed versions of Java.