Skip to main content
Browse topics

JDK JRE JVM Explained Example in Java

1 min read Updated May 29, 2026
Share

Introduction

Before writing advanced Java programs, it helps to understand how source code becomes running output. Three terms appear constantly: JDK, JRE and JVM.

Comparison

ComponentRole
JDKFull development kit — compiler (javac), tools, JRE
JRERuntime environment — libraries + JVM (execute only)
JVMVirtual machine that runs bytecode on any supported OS

Execution Flow

plaintext
Hello.java  --javac-->  Hello.class (bytecode)  --JVM-->  Program Output
     ^                        ^                          ^
   JDK tool                 JRE/JVM                   Running process

Example Program

java
public class JdkDemo {
    public static void main(String[] args) {
        System.out.println("Java Version : " + System.getProperty("java.version"));
        System.out.println("JVM Name     : " + System.getProperty("java.vm.name"));
        System.out.println("JRE Vendor   : " + System.getProperty("java.vendor"));
        System.out.println("OS Name      : " + System.getProperty("os.name"));

        int a = 10, b = 20;
        System.out.println("Sum = " + (a + b));
    }
}

Sample Output

plaintext
Java Version : 21.0.2
JVM Name     : OpenJDK 64-Bit Server VM
JRE Vendor   : Oracle Corporation
OS Name      : Windows 11
Sum = 30

How It Works

  1. You write .java source and compile with javac (part of the JDK).
  2. The compiler produces platform-independent bytecode in .class files.
  3. The JVM (inside the JRE) interprets or JIT-compiles bytecode and runs main.
  4. System.getProperty queries runtime details exposed by the JVM.

Best Practices

Common Mistakes

Frequently Asked Questions

What is the difference between JDK and JRE?
JRE provides the runtime (JVM + libraries) to execute Java programs. JDK includes the JRE plus development tools such as javac, jar and javadoc needed to write and build programs.
What does the JVM do?
The JVM loads bytecode (.class files), verifies it, executes it and manages memory through garbage collection.

Related tutorials

Search tutorials