How To Install And Run Java Easily On Kali Linux

 

Welcome To My Blog, this is a short Tutorial to guide you through the easiest method of installing java on Kali Linux, read this till then end and follow the procedures as shown and java will be running on your machine in no time.

Installation Procedures:

Below are the procedures you need to follow to get java  installed and running.

Updating Repo and Installing Java

Launch your Terminal and update your repositories with the command below
apt update 

After updating your Terminal, install java with the command below.

apt install default-jdk 

 Now that java is installed, it is important o check your java version and be sure that it is running perfectly fine on your phone. You can do that with the Command below.

java --version

 Running a java program on Kali Linux 

To run a java program, open any text editor of your choice and write a java code, in my case I am running a simple "Hello World" code just for demonstration purpose.

code :

public class hello{  
    public static void main(String[] args) {  
        // Prints "Hello, World" to the terminal window.  
        System.out.println("Hello world");  
    }  
  
}  

 After writing your code, save the program as code-name.java e.g "hello.java" and compile it with the command below 

Command :

javac "code-name.java"

Example :

javac hello.java 

Once the program gets compiled successfully, you can now run the program with the command below.

java hello.java

Result :  



Post a Comment

Previous Post Next Post