DEV Community

MANOJ K
MANOJ K

Posted on

Today at payilagam institute


To run a Java program in Linux using the terminal:
First, create a .java file in any folder and write your program inside it.
Open the terminal, go to the folder where the file is saved using the cd command.
Compile the program with:
javac FileName.java
If there are errors, fix them and compile again. After compiling, a .class file is created.
.java file = source code (human readable).
.class file = bytecode (machine readable).
Run the program with:
java FileName
This will execute the program and show the output.

Top comments (0)