Difference Between JDK JRE and JVM

JVM

Java Virtual Machine is a program that runs pre compiled Java programs, which mean JVM converts each bytecode(.class files) instruction into the machine language instruction that can be executed by the microprocessor.

First, .java source files are compiled into .class files by the javac compiler. This .class file is given to the JVM which has Class Loader Sub System to perform the following instructions:

  • Load the .class file into memory
  • Verify the bytecode. Any suspicious execution is rejected.
  • Executes the bytecode.

It also provides some additional features like memory management, garbage collection, fatal error reporting.

JVM makes Java platform-independent. Because of the JVM, a .class file can be executed in multiple platforms without any platform specific changes. Different platforms have their our JVM's
which provides abstraction over platform specific implementation details. There are many JVM implementations developed by different organizations for different platforms.


JRE

Full form of JRE is Java Runtime Environment. JRE is an implementation of the JVM which actually executes Java programs. It combines the Java Virtual Machine with core classes and libraries required for running java applications.

JRE is required to execute a Java application, however it doesn't contains necessary modules for development of java applications. Remember, JRE is a superset of JVM but subset of JDK.


JDK

The full form of JDK is Java Development Kit. JDK is a set of java modules required for development and execution of a java application.

JDK includes the JRE, Java compiler, javap and other development tools. JDK is a superset of JRE.