Tuesday 7 August 2018

IMPLEMENTING A JAVA PROGRAM



Steps to be followed to implement a Java Program:
Creating the program
Compiling the program
Running the program

Creating the program
We can create a program using any text editor.
Class Sample
{
public static void main(String args[])
{
System.out.println(“ HELLO “);
}
}
We must save this program with the filename Sample.java ensuring that the filename and
classname should be same. This file is called as source file. If a program contains multiple
classes, the filename must be the classname of the class containing the main method.

Compiling the program
C:\> javac Sample.java
The javac compiler creates a file called Sample.class that contains the bytecode version of the
program.

Running the program
C:\> java Sample
Now the interpreter looks for the main method in the program and begins execution from
there.

No comments: