The Wayback Machine - https://web.archive.org/web/20250128005104/https://www.geeksforgeeks.org/differences-jdk-jre-jvm/
Open In App

Differences between JDK, JRE and JVM

Last Updated : 21 Jan, 2025
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Understanding the difference between JDK, JRE, and JVM plays a very important role in understanding how Java works and how each component contributes to the development and execution of Java applications. The main difference between JDK, JRE, and JVM is:

  • JDK: Java Development Kit is a software development environment used for developing Java applications and applets.
  • JRE: JRE stands for Java Runtime Environment and it provides an environment to run only the Java program onto the system.
  • JVM: JVM stands for Java Virtual Machine and is responsible for executing the Java program.

JDK vs JRE vs JVM

Aspect

JDK

JRE

JVM

Purpose

Used to develop Java applications

Used to run Java applications

Responsible for running Java code

Platform Dependency

Platform-dependent

Platform-dependent

Platform-Independent

Includes

It includes development tools like (compiler) + JRE

It includes libraries to run Java application + JVM

It runs the java byte code and make java application to work on any platform.

Use Case

Writing and compiling Java code

Running a Java application on a system

Convert bytecode into native machine code

Note: The JVM is platform-independent, but JVM implements differently in each platform because it interacts with the native operating system and the hardware. So it is in practice, platform dependent.

We have discussed the core differences, now let’s take a closer look at each component. let us discuss them in brief first and interrelate them with the image below proposed.

JDK vs JRE vs JVM

JDK(Java Development Kit)

The JDK is a software development kit that provides the environment to develop and execute the java application. It includes two things:

  • Development Tools (to provide an environment to develop your java programs)
  • JRE (to execute your java program)

Working of JDK

The JDK enables the development and execution of Java programs. Consider the following process:

  • Java Source File (e.g., Example.java): You write the Java program in a source file.
  • Compilation: The source file is compiled by the Java Compiler (part of JDK) into bytecode, which is stored in a .class file (e.g., Example.class).
  • Execution: The bytecode is executed by the JVM (Java Virtual Machine), which interprets the bytecode and runs the Java program.
JRE_JDK_JVM

Note: From above, media operation computing during the compile time can be interpreted.

The following actions occur at runtime as listed below:

  • Class Loader
  • Byte Code Verifier
  • Interpreter
    • Execute the Byte Code
    • Make appropriate calls to the underlying hardware

JRE((Java Runtime Environment)

The JRE is an installation package that provides an environment to only run(not develop) the Java program (or application) onto your machine. JRE is only used by those who only want to run Java programs that are end-users of your system.

Working of JRE

When you run a Java program, the following steps occur:

  • Class Loader: The JRE’s class loader loads the .class file containing the bytecode into memory.
  • Bytecode Verifier: The bytecode verifier checks the bytecode for security and correctness.
  • Interpreter: The JVM interprets the bytecode and executes the program.
  • Execution: The program executes, making calls to the underlying hardware and system resources as needed.

JVM (Java Virtual Machine)

The JVM is a very important part of both JDK and JRE because it is contained or inbuilt in both. Whatever Java program you run using JRE or JDK goes into JVM and JVM is responsible for executing the java program line by line, hence it is also known as an interpreter.

Working of JVM

It is mainly responsible for three activities. 

  • Loading
  • Linking
  • Initialization


Next Article
Practice Tags :

Similar Reads

three90RightbarBannerImg