What is the difference between JVM, JDK, JRE & OpenJDK?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
When developing or running Java applications, it's essential to understand the roles of Java Development Kit (JDK), Java Virtual Machine (JVM), Java Runtime Environment (JRE), and OpenJDK. Each component serves a specific purpose in the ecosystem of Java, one of the most popular programming languages.
Java Virtual Machine (JVM)
The JVM is an abstract computing machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is platform-independent, meaning that Java programs can be transferred and executed on any system that has a JVM installed, adhering to the philosophy of "write once, run anywhere" (WORA).
The main function of the JVM is to load code, verify it, execute it, and provide runtime functionality like memory management and dynamic linking. JVM also includes the Just-In-Time (JIT) compiler that improves the performance of Java applications by compiling bytecode into native machine code at runtime.
Java Runtime Environment (JRE)
JRE is a part of the JDK but can also be distributed separately. It essentially provides the libraries, the Java Virtual Machine (JVM), and other components needed for the applications to run. JRE does not contain tools and utilities such as compilers or debuggers for developing applets and applications. JRE is essentially the container that provides the runtime environment where Java bytecode can be executed, making it essential for running Java-based software.
Java Development Kit (JDK)
JDK includes JRE and other tools such as compilers (javac), JavaDoc, Java debugger, etc., which are required to develop Java applications and applets. JDK is the full featured Software Development Kit for Java, including everything someone would need to write, test, and debug Java applications and applets. When you download JDK, you get JRE as well, along with an array of different tools and libraries.
OpenJDK
OpenJDK is the open-source implementation of the Java Standard Edition platform with contribution from Oracle and the Java community. It is a free and open-source alternative to Oracle's JDK and functions as a platform to develop Java applications. OpenJDK is the official reference implementation of Java SE since version 7. The main difference between JDK and OpenJDK is that JDK comes from Oracle with a few additional components like JavaFX, whereas OpenJDK is purely open-source Java tools.
Comparison Table
| Component | Description | Required For | Include in Development? |
| JVM | Execution environment for Java bytecode. Part of JRE. | Running Java apps | No |
| JRE | Contains JVM and core libraries and other components to run applications. | Running Java apps | No, unless only running apps |
| JDK | JRE + development tools like compiler & debugger. | Developing Java apps | Yes |
| OpenJDK | Open-source implementation of JDK. | Developing Java apps | Yes |
Key Differences
- Purpose: JVM is mainly for executing applications, JRE is for running them, JDK is for developing them, and OpenJDK is an open-source version of JDK.
- Components: JDK contains JRE, which in turn contains JVM. JDK and OpenJDK include additional tools for application development not present in JRE.
- Use Case:
- JRE: You need only JRE if you are interested in running Java programs, but not developing them.
- JDK/OpenJDK:
- If you're developing Java applications, you need JDK or OpenJDK.
- If you prefer open-source tools, OpenJDK would be the preferable choice.
Understanding these differences is key in choosing the right tools for Java application development and deployment. Utilizing JVM, JRE, JDK, and OpenJDK according to their strengths is essential in creating efficient and portable Java applications.

