0
0
Javaprogramming~5 mins

JDK, JRE, and JVM difference in Java

Choose your learning style9 modes available
Introduction

JDK, JRE, and JVM are parts of Java that help run and create Java programs. Knowing their difference helps you understand how Java works.

When you want to write and compile Java programs.
When you want to run Java programs on your computer.
When you want to understand how Java executes your code.
When you need to set up your computer to develop Java applications.
When you want to troubleshoot Java program errors.
Syntax
Java
No code syntax applies here because these are tools and components, not code statements.

JDK stands for Java Development Kit.

JRE stands for Java Runtime Environment.

Examples
JDK includes everything in JRE plus tools to write and compile Java code.
Java
JDK = JRE + tools for development (like compiler)
JRE includes JVM and the libraries needed to run Java programs but not to develop them.
Java
JRE = JVM + libraries to run Java programs
JVM is the part that actually runs the Java program on your computer.
Java
JVM = Java Virtual Machine that runs Java bytecode
Sample Program

This simple Java program prints a message. To run it, you need JRE and JVM. To write and compile it, you need JDK.

Java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, Java!");
    }
}
OutputSuccess
Important Notes

You need JDK to write and compile Java programs.

You need JRE to run Java programs.

JVM is inside JRE and runs the Java program.

Summary

JDK is for developing Java programs (write + compile + run).

JRE is for running Java programs only.

JVM is the engine that runs Java bytecode inside JRE.