Thursday, June 22, 2017

Java-Execution process of a java program

Execution Process c and cpp program
---------------------------------------------
*if we develop any program it has to undergo 2 phases

i)compilation
ii)execution

if we compile a c/cpp program we get an intermediate code called as .obj file.

*we execute or convert .obj into .exe using a program called Linker.

*.exe is when executed provides output.


Here either .obj or .exe of one os cannot be executed on other os,so c/cpp are platform dependent.


.c/.cpp-->compile-->.obj-->Linker-->.exe



Execution Process of a java program
-----------------------------------

.java--->comiple-->.class[bytecode]--->Jvm-->o/p
                                       Jit

*we save a java program using the extension .java

*Execution of a java program undergoes 2 phases

i)compilation
ii)execution

i)compilation

*if we compile a .java program we get .class[bytecode]

.java-->compiled-->.class[bytecode]

*once we get a .class again we should convert bytecode to machine code using jvm[java virtual machine]

*Jvm is a program which helps in converting bc to mc

.class-->jvm-->o/p

*.class is platform independent code,we can execute the .class file of one os on another os.

*.class is interpreted by jvm so jvm is also called as bytecode interpretor.

*jvm is platform dependent bcoz every os should have a seperate jvm.

what is JIT compiler?

It is a helper application of jvm which helps jvm to convert byte code to mahcine code together.



.java-->compile-->.class-->jvm-->o/p.


No comments: