DEV Community

KIRUBAGARAN .K
KIRUBAGARAN .K

Posted on

How to Run a Java Program in Linux Terminal

Step 1: Create a .java file

First, create a folder to store your Java program.

Inside that folder, create a .java file using any text editor .

Step 2: Open Terminal and Go to the File Location

Open the terminal.

Use the command to move into the folder where your .java file is saved

Step 3: Compile the Java Program

To compile, run.

If there are any errors, they will be shown in the terminal. Fix them, save the file, and recompile.

After successful compilation, a new file named class will be created in the same folder.

Step 4: Run the Java Program

Run the compiled program using the java command

You will see the output of your program in the terminal.

    That's it for today 
         Thank you 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)