Логотип Workflow

Article

Jvm Jdk Jre

Topic 2. JVM, JDK, JRE

This topic is not about memorizing abbreviations. It is about practical execution flow: install Java correctly, compile code, run code, and quickly diagnose environment issues.

Why JVM, JRE, and JDK are different layers

Java has three execution layers, each with a different responsibility:

  1. JVM executes bytecode (.class) and controls runtime execution.
  2. JRE provides runtime components: JVM + standard libraries required to run applications.
  3. JDK provides development tools: compiler, diagnostics, packaging, and debugging utilities.

Practical rule:

  • If you write and compile Java, you need JDK.
  • If you only run an already built app, you need runtime components.
  • In modern Java setups, teams usually install JDK everywhere for consistency.

What the JVM does in practice

When you run java App, JVM:

  1. loads classes (ClassLoader),
  2. verifies bytecode,
  3. allocates and manages memory,
  4. interprets and JIT-optimizes hot code paths,
  5. bridges Java code with OS-level resources.

This is why the same bytecode can run across different operating systems.

What JRE provides

JRE answers: “What is required to run this app reliably at runtime?” It includes:

  • JVM,
  • core Java libraries (java.lang, java.util, java.io, etc.),
  • runtime support components.

Without correct runtime components, even valid code may fail to launch.

What JDK provides

JDK is for development workflows. Typical tools:

  • javac compiles .java into .class,
  • java launches the app,
  • javadoc generates API docs,
  • jdb, jcmd, jstack, jmap help debug and diagnose runtime behavior.

Layer relationship:

  • JDK includes runtime components.
  • Runtime components include JVM.

JDK JRE JVM

Minimal build-run cycle (beginner flow)

Step 1. Create the file

public class App {
    public static void main(String[] args) {
        System.out.println("Runtime via JVM");
    }
}

Step 2. Compile

javac App.java

Compiler from JDK produces App.class.

Step 3. Run

java App

JVM loads bytecode and executes main.

Step 4. Check environment if it fails

java -version
javac -version
echo $JAVA_HOME
which java
which javac

Common failure patterns

  1. java and javac show different major versions. Cause: mixed binaries in PATH.

  2. JAVA_HOME points to an old installation. Cause: environment variables were not updated.

  3. App is built on Java 21 but runs on Java 17. Cause: inconsistent versions between local, CI, and production.

Team rule: lock one target Java version and enforce it across local dev, CI, and runtime.

Key takeaway

  • JDK is the developer toolkit.
  • JVM executes application code.
  • Most Java startup/build issues are environment consistency problems, not business logic bugs.

Quiz

Check what you learned

Please login to pass quizzes.