Friday 10 November 2017

Java : Compiling and Executing Java Program

A program has to be converted to a form that Java Virtual Machine can understand, so any computer with a Java Virtual Machine can interpret and run the program. Compiling a Java program means to convert source code into byte code, which are platform independent.

The Java compiler is invoked at the command line as follows:
C:\>javac prg1.java

Executing the program
Once your program is successfully compiled that means converted into byte codes, you can interpret and run application on any Java VM. Interpreting and running a Java program means invoking the Java VM byte code interpreter, which converts the Java byte codes to platform-dependent machine codes so your computer can understand and run the program.
The Java interpreter invoked at command line as follows:
C:\>java prg1.class

And finally you will see output on command line.


No comments:

Post a Comment