Difference Between JDK, JRE, and JVM
JVM (Java Virtual Machine)
The JVM is an abstract computing machine, having an instruction set that uses memory. The JVM is the virtual machine that runs the Java byte codes. When Java program (*.java) compiles it generates a class (*.class) file that contains the byte codes understandable by JVM.
JVM has different implementation for different operating systems like Windows, Linux, Mac, and UNIX. It makes Java programs portable which means write once and run anywhere. In other words, Java programs (*.class) are platform independent but JVMs are platform dependent.
JRE (Java Runtime Environment)
A Java distribution comes in two parts, one part is Java Runtime Environment (JRE) and another part is Java Development Kit (JDK). JRE consists of JVM and the Java class libraries and contains the necessary functionality to execute Java applications and programs.
JRE provides a whole environment where our Java programs run. It loads all the dependent libraries at run time and provides smooth execution of the program. Memory management is one of the most important services of JRE and it ensures that programmers don’t need to control the memory allocations and deallocation manually.
JDK (Java Development Kit)
The JDK is the superset of JRE and contains everything that is in the JRE. JRE, JVM, libraries, class loader all are the parts of JDK. If we have JDK installed then we can compile our programs as well run but if we have JRE installed then we can only run our programs as it provides an only runtime environment.