Wednesday, 22 January 2014

Difference between jdk jre jvm and jit

Java is called as platform independent because it can run in any of the operating system, if   jre/jdk is(Java Run-time Environment) installed on it.  There are different jre's/jdk's  depends on operating system which can talk with it's OS. But all the jre's/jdk's use a common language called byte code. The java compiler reads the source code and and converts that to class file which can be understood by java interpreters of all the jre's independent of the operating system.
So the java source code compiled in a window's system can be run in ubuntu system or vice versa.

Different jdk's for each operating system has it's own compilers,interpreters  and java virtual machine packed together as a single unit which makes it easy to run independent of the platform.
Generally when we install JDK, it installs many components. The main components are Java Compiler(javac), Java Interpreter (java), and JRE.

Overview :
jdkdiagram

JDK:
JDK = java utilities (Compiler, Interpreter etc..)+ JRE
JDK contains JRE along with many utilities like java compiler , java interpreter, applet viewer, jar achiever etc..  This provides complete set of tools to java programmer to compile, load,interpret and execute the code in a platform independent manner.

JRE:
JRE = JVM + Class loader + Class libraries
JRE is Java runtime environment which has JVM, Class loader, byte code verifier and class libraries. The compiled byte code will be given to JRE, then JRE does the following main processes.

  • JRE's class loader loads the required .class files into memory

  • JVM instance will be created  and it executes the class files.


JVM:
JVM = Java Interpreter + jit+ Garbage Collector + threads and synchronization +..
JVM is the computing machine where, it interprets, and executes the byte code. It has a instruction set which uses memory and it handles garbage collection, synchronization and threading etc..

JIT:
JIT is a compiler inside JRE. JIT compiler compiles the byte code to the native code of operating system in which it runs and thus it increases the performance.

No comments:

Post a Comment