Wednesday 9 November 2016

Java Source World: JDK, JRE, JVM, JIT Compiler

JVM Architecture | Java Source World

                                                                                                   



JVM Architecture:


JDK

Java Development Kit  contains tools which  a java developer needs the java programs and JRE to run the program.

Suppose if you want to write your own codes compile and run then only JDK is required. Just for running the already compiled code then JRE is alone sufficient.

In simple terms  we can say  that JDK is equal to RE and development tools. The tools include Java compiler(java c) , Java disassembler(java p) , Java debugger(jd b), Java header file generator(java h), Documentation(java doc) and many others.

                                                JDK = JRE + Developement Tools

JRE

Java Runtime Environment is typically the implementation of a  JVM. It consists of JVM , class libraries and other supporting files(java , javaw , etc) required for execution.
JVM runs the programs it uses the libraries provided in the JRE. It doesn’t  contain development tools  such as compiler(java c) , disassembler(java p), debugger(jd b) etc.
In simple terms we can say JRE is equal to JVM and libraries.

                                                JRE = JVM + Libraries.




                                                                    JVM Architecture




JVM

JVM is an abstract machine which  provides a specification for the runtime environment where the byte code will be executed.

The compiled java code(class file) act as the input for the JVM as it can understand java java byte code only.

JVM itself is actually platform development.

It interprets the byte code into machine level language which can then be executed by any JVM implementation.



JVM has three major components: 


Class Loader Sub System:

Loading (loads the required class/java files), linking(assigning references and verification) and initialization (initializing static variable and execution of static block).

Runtime data area:    

Provides  memory  for  all variables, operators etc.

Execution Engine:

Performs  the  interpretation  and  execution.

JVM = Class loader system + runtime data area + Execution Engine.


Why JIT Compiler?


JIT Compiler:

Before knowing about JIT compiler we need to have some basic knowledge about how an Interpreter works in java.

Interpreter reads the java byte code interprets it and executes it one by one.

The interpreter interprets the  java byte code faster but executes slowly.

The disadvantage of an interpretor is that  when one method is called multiple times each and every time interpretation is required.

JIT compiler helps us to overcome the disadvantage of the Interpreter (the single method is interpreted multiple times for multiple calls). The  Execution Engine uses Interpreter to read and interprets the byte code but when it come across repeated code itt uses JIT compiler which compiles the entire java byte code once and changes it to native code.



                                                                                                  




No comments:

Post a Comment