Saturday, May 18, 2013

Difference between JVM, JRE and JDK

JVM (Java Virtual Machine)
As the name suggest, it provides virtual machine in which java programs can be executed. It is a specification that provides run-time environment in which java byte code can be executed.
JVM is platform dependent but makes JAVA programs platform independent.

Java Virtual Machine interprets the byte code into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc.

JRE (Java Runtime Environment)
Java Runtime Environment contains JVM, class libraries(like util, math, lang, awt,swing etc), and other supporting files. JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE. If you want to run any java program, you need to have JRE installed in the system
It does not contain any development tools such as compiler, debugger, etc.

It is the implementation of JVM. It exist with JDK installation as well as installer of JDK itself is available.
If you just want to run applets (ex: Online Yahoo games or puzzles), JRE needs to be installed on the machine.

JDK (Java Development Kit)
Java Developer Kit contains JRE and and java development tools like compiler (javac.exe).

You need JDK, if at all you want to write your own programs, and to compile the program. For running java programs, JRE is sufficient.

1 comment:

  1. I would like to add that many a times we need JDK only with JAVA_HOME pointing to the root of JDK and at other times JRE is sufficient with JRE_HOME enviornment variable being set properly. For e.g. Eclipse shall need JDK for compiling programs where as a server like Tomcat can work with JRE. See more differences between JVM, JRE and JDK

    ReplyDelete