Java-Implementing Java Program

Implementing Java Program

Implementation of a Java application program involves a series of steps. They include :

  • Creating the program
  • Compiling the program
  • Running the program

Creating the program

We can create a program using any text editor. Assume that we have entered the following program :

class Javaapp {
  
    public static void main(String[] args) {
       
        System.out.println("hajsoftutorial");
    }
}

We must save this program in a file called Javaapp.java ensuring that the file name contains the class name properly. This file is called the source file. Note that all Java source files will have the extension java.

Compiling the program

To compile the program, we must run the Java Compiler javac, with the name of the source file on the command line as shown below :

If everything is OK, the javac compiler creates a file called Javaapp.class containing the bytecodes of the program. Note that the compiler automatically names the bytecode file as <classname>.class.

Running the program

To run the program, we must run the Java interpreter java, with the name of the class file on the command line as shown below :

Now, the interpreter looks for the main method in the program and begins execution from there. Note that we simply type “Javaapp” at the command line and not “Javaapp.class” or “Javaapp.java“.

 

Leave a Comment