Differences between JDK JRE and JVM

JDK (Java Development Kit), JRE (Java Runtime Environment), and JVM (Java Virtual Machine) are three key components of the Java platform. Understanding the differences between these components is important for anyone working with Java.

  1. JVM (Java Virtual Machine)

JVM (Java Virtual Machine) is a virtual machine that executes the compiled Java code. It acts as an intermediary between the Java code and the underlying hardware. JVM is responsible for allocating memory, managing memory, and executing the bytecode. JVM also provides security by enforcing Java's access restrictions and type checking. The JVM specification is standardized by the Java Community Process (JCP), and different implementations of the JVM are available from different vendors.

  1. JRE (Java Runtime Environment)

JRE (Java Runtime Environment) is a set of software tools that provides a runtime environment for executing Java code. It includes the JVM and the Java class libraries, which provide a rich set of APIs for developing Java applications. JRE also includes a browser plugin that allows you to run Java applets in a web browser.

  1. JDK (Java Development Kit)

JDK (Java Development Kit) is a complete set of tools for developing Java applications. It includes the JRE, as well as a set of development tools such as the Java compiler, debugger, and performance analyzer. The JDK also includes a set of header files, tools, and utility programs that are required for developing Java applications.


Suppose you want to write and run a Java program that calculates the factorial of a number. You would start by writing the Java source code in a text editor, then use the Java compiler that is included in the JDK to compile the source code into bytecode. The bytecode is then executed by the JVM. The JRE provides the necessary runtime environment for the program to run, including the JVM and the Java class libraries.

In conclusion, JDK is a complete set of tools for developing Java applications, including the JRE, development tools, and header files. JRE provides the runtime environment for executing Java code, including the JVM and the Java class libraries. JVM is responsible for executing the compiled Java code, managing memory, and providing security.