Javatpoint Logo
Javatpoint Logo

How to run a java program on Kail Linux?

If you want to run the java program on Kali Linux, you need to install the latest version of Java JDK on your kali Linux just like we do in any other operating system. So in order to run a java program, you first need to know how to install Java on your system. Therefore in this guide, we will cover the following given point:

  • How to install Java on Kali Linux?
  • Running a java program on Kali Linux

How to install Java on Kali Linux?

Welcome to our article on Installing the latest Java JDK on Kali Linux. It is quite possible that you may know several applications that strictly requires Java installation on your computer in order to run smoothly. All java developers and coders also use it in order to compile and run the java applications on their systems. Java Installation is also required by several security tools that are built-in Java. However, it is impossible to discuss all uses of Java here, but these are some of the most crucial uses of Java. Therefore, this guide will help you through a complete process of installing the latest version of Java on your Kali Linux operating system.

Most articles you read online will provide you a hard and confusing procedure to follow, but here we will provide you a straightforward guide, and you will always get the latest version of Java on your distribution.

Installation

To install Java on Kali Linux, follow the instructions below:

1. First of all, open the web browser, type download java JDK and click on the search button.

How to run a java program on Kail Linux?

2. Once the search gets completed, click on the first link & search for the Linux version of the Java JDK, and download it as shown below:

How to run a java program on Kail Linux?

3. When the downloading gets completed, copy or move the downloaded file to the desktop and extract it.

4. Now open the terminal, log in as the root user or switch to the root account and execute the following given command as shown below:

Command

Output

How to run a java program on Kail Linux?

5. Here you need to execute the following given command to grant the necessary permissions.

Command

Output

How to run a java program on Kail Linux?

6. Next, type the command "mv jdk-16.0.2" and press enter to execute the command:

How to run a java program on Kail Linux?

7. Here type the "/opt" and execute the command by pressing the enter button to change the current directory as shown below:

How to run a java program on Kail Linux?

8. Now type the following given command and press enter to execute the command to install the java.

Command

Output

How to run a java program on Kail Linux?

9. Next, you need to execute the following given commands one by one as show below:

  • Command1

Output

How to run a java program on Kail Linux?
  • Command2

Output

How to run a java program on Kail Linux?
  • Command3

Output

How to run a java program on Kail Linux?
  • Command4

Output

How to run a java program on Kail Linux?

10. Now you can type the "exit" command and press the enter button because all work is done here. In case you want to check that the Java is successfully installed or not. You can do so by typing the following command.

Command

Output

How to run a java program on Kail Linux?

As you can see in the above-given image, Java is successfully installed in your system. I know you may think that how long this process is, but trust me, it is not that boring, and you have to perform this process only once in a lifetime until you replace your system. Now without wasting much of your precious time, let us see how to run a java program on Kali Linux.

Running a Java program on Kali Linux

To run the java program on your kali Linux, follow the following given instructions carefully:

Step 1. Open any text editor or notepad on your system, and here I am using the simple notepad.

Step 2. After opening the text editor, type or write your java program. In my case, I will write a simple "hello world" program for the demonstration purpose.

Program

Step 3. After writing the program code, save the program as "hello.java" and close the text editor. Now open the terminal and type the command given below to compile your java program:

Command

Example

Output

How to run a java program on Kail Linux?

Step 4. Once the program gets compiled successfully now you can run the program by using the following given command:

Command

Output

How to run a java program on Kail Linux?

Here we can see that our program is successfully executed, and output is displayed in the terminal.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA