Java Compilation and Interpretation Process

Above figure shows compilation & Interpretation process

Following steps explains how it works:-

  •  We create  a program using program editor(eg. Notepad) and save it as file in specified directory.
  •  Then we compile it using javac command(eg. javac, A java compiler then convert .java file into .class file which is called as bytecode and this bytecode is platform independent can run on different platforms eg.Windows, Linux,MAC etc.
  • If any bugs found during compilation that should be fixed first then compiled again, If there is not any bugs found  then bytecode is created and handed over to JVM(java virtual machine) for interpretation.
  • JVM interpret class file by running java space class name command(eg. java filename)  as given in figure.
  • JVM has three components to interpret program first: Bytecode verifier which verifies bytecode, second: Class loader which loads required classes from java class library, third one is a JIT(just in time) compiler which compiles class file and convert it into machine readable format and then hand over to operating system.
  • If there any bugs(mostly logical) found during interpretation(by JVM) then one have to edit program to fix bugs and compile it again.If not any more bugs then final output will be displayed on screen.           

Note: It's not necessary to have same class name and file name. Thing is that file name is required during compilation and class name is required during interpretation but it would be great to use same name for class and file(file name is a name by which we store program).Also compilation process actually figure out any syntactical error while interpretation checks logical error.


Komal Pawar said...

Awesum answer n very easily explained thanx 4 the post

Mridula said...

The blog describes the compilation process very well. The byte code produced during the process accounts for platform independence of the language. JVM converts the application into byte code.

Post a Comment


Copyright © 2012 All rights reserved |Term of Use and Policies|