How to name a Java source file and how to compile and run a java program?

A java source file can be named by using the extension .java. For Example, here is a sample file:



class Process {

public static void main(String args[]) {

System.out.println(“More Process”);



And it is named as Usually the class name used in the program is taken for a filename. Well, this is just done to make things simple and you can name your file anything. Java is a case sensitive language so when you are naming a file and reusing it you have to enter the filename in proper case.

To compile the above given line, enter in command prompt:


Where, javac is the compiler. javac compiler compiles the program and converts it in to bytecode. It creates a class Process.class to save the bytecode version of the program. This is just the conversion of the program to bytecode. Now to run the program, enter the following in command line:

C:\>java Process

The output of the above program will be:

More Process

Leave a Reply