Thursday, August 15, 2013

About Jdk,jre and jvm

   Things to Know about JDK,JRE and JVM

This is a favorite interview topic . Even though this is the most basic  information a java programmer must know, many fail to answer it perfectly. I am making an attempt to rewrite this information so that it will refresh the concept of few experienced and will help java beginners to know concept  in depth.
The below diagram should make things clear.

JDK:
Java Development Kit (JDK) = Java Runtime Environment (JRE) + Tools like compilers (JavaC)and debuggers necessary for developing java programs.
JRE:
JRE = Java Virtual Machine(JVM) + Java Runtime Libraries  + Components necessary to execute programs or applications written in java language.
JVM:
Programs written in Java are not directly compiled by Java Compiler (JavaC) for a particular hardware and operating system platform for execution.
Instead Java programs are compiled for an intermediate language called byte code which can be interpreted  by an virtual machine [A software ] called Java Virtual Machine (JVM). And this interpreted code can now run on the actual hardware and OS.
JVM thus makes java programs independent of the underlying hardware or operating system . So Java programs written on one platform need not change while attempted running it on a different code. Because Java programs are written for JVM's rather than actual machine it self.
Different platforms are provided with its on JRE which in turn includes the JVM for a particular platform. Means to say JVM for windows 32 bit machines and JVM for Linux 64 bit machines are different. However a java program written on the windows system can run on Linux 64 bit machine without any issues because, both JVM's can understand byte code.
However while interpreting into actual machine language , individual JVM's will take care of interpreting it correctly.
The below diagram should make things clear.
But one thing with interpreting the byte code is that it will make the execution slower. Now newer JRE's have capability for Just in Time compilation [JIT] which makes the compilation much faster.
I will write on this in my next blog.
Please share in your thoughts. Hope it benefited you.


No comments:

Post a Comment