How to install Java JDK 17 on Kali Linux 2022

In this article, we will see how to install Java JDK 17 on Kali Linux 2022 step by step.

How to install Java JDK 17 on Kali Linux 2022

1. Update the packages in kali Linux 2022 using the following command.

sudo apt update

2. Install Java jdk 17 using the below command.

sudo apt-get install openjdk-17-jdk openjdk-17-jre

How to install Java JDK 17 on Kali Linux 2022

Now, it will ask us for confirmation. Type y and hit enter.

3. After installation verify java is installed or not on Kali Linux by running below command.

java --version

Set the JAVA_HOME Environment Variable in Kali Linux 2022

1. Find the java installed location using below command.

readlink -f /usr/bin/java

2. Now, open /etc/environment file.

sudo nano /etc/environment

Add the following line at the end of the file, make sure to replace the location of your Java installation path.

JAVA_HOME="/usr/lib/jvm/java-1.17.0-openjdk-amd64"

3. Save the file and reload the file to apply the changes to your current session:

source /etc/environment

4. Verify that the environment variable is set or not.

echo $JAVA_HOME

5. reate and run sample java program on Kali Linux 2022.

Create and run sample java program on Kali Linux 2022.

1. Create a file using nano and paste below program in the file and save it.

class r2schools{ public static void main(String args[]){ System.out.println("Welcome to r2schools"); } }

2. Compile the java file.

javac helloworld.java

3. Run the java program.

java r2schools

Watch below video for the same steps:

Leave a Reply

Your email address will not be published. Required fields are marked *