PrepZone Logo
PrepZone

JVM, JRE and JDK

Three names people use interchangeably, what each one actually contains, and which you need when.

Read these first

Why this matters

  • Choosing the wrong download is the first thing that goes wrong for a beginner — a JRE cannot compile, so javac is simply absent.
  • Docker images are sized around this distinction, and shipping a build toolchain into production is wasted space and extra attack surface.
  • The relationship between the three is asked in almost every first-round interview, and a vague answer is noticed immediately.

What each one is

From the inside out

  • JVM — Java Virtual Machine. The engine. It loads bytecode, verifies it, executes it, and manages memory. It is a specification with multiple implementations, and it cannot be installed by itself.
  • JRE — Java Runtime Environment. The JVM plus the standard class library: java.lang, java.util, java.io, the collections, everything your code imports without adding a dependency. This is the minimum needed to run a compiled program.
  • JDK — Java Development Kit. The JRE plus the development tools: javac the compiler, jar the packager, javadoc the documentation generator, jdb the debugger, javap the bytecode viewer, and jshell the interactive shell.
JDK — build and run
javacCompiler
jdbDebugger
jar / javadocTooling
JRE — run only
Class librariesjava.lang, java.util, java.io
JVM — the engine
Class loader
Memory areas
Execution engine
Install the JDK to write code. The JRE is the subset needed only to run it, and the JVM is the engine inside both.

Which one you actually need

AspectJRE is enoughJDK is required
TaskRunning an already-built applicationCompiling source, or building a jar
Typical userA production server, an end userA developer, a CI pipeline
Has javacNoYes
Disk footprintSmallerLarger
Frameworks that compile at run timeNot supportedSupported
  • Task

    JRE is enoughRunning an already-built application
    JDK is requiredCompiling source, or building a jar
  • Typical user

    JRE is enoughA production server, an end user
    JDK is requiredA developer, a CI pipeline
  • Has javac

    JRE is enoughNo
    JDK is requiredYes
  • Disk footprint

    JRE is enoughSmaller
    JDK is requiredLarger
  • Frameworks that compile at run time

    JRE is enoughNot supported
    JDK is requiredSupported

In practice, install the JDK on your own machine and the smallest possible runtime in production.

Proving the difference

Java
java -version    # present in both a JRE and a JDK
javac -version   # only present in a JDK

If the second command reports "command not found" while the first prints a version, you have a runtime and not a development kit. That is the whole diagnosis.

A single-file program can skip the explicit compile step entirely, which sometimes hides the distinction:

Java
java Greeting.java   # compiles in memory and runs — still needs a JDK

This is convenient for scripts, but it is the JDK's compiler doing the work behind the scenes. On a JRE the same command fails.

Specification versus implementation

The JVM is defined by a written specification, so several organisations build their own. They all run the same bytecode, but they differ in licensing and in extras.

  • HotSpot is the reference implementation, used by Oracle JDK and by Eclipse Temurin. Its name comes from the way it detects hot code to compile.
  • OpenJDK is the open-source codebase that nearly every distribution is built from. Amazon Corretto, Azul Zulu and Temurin are all builds of it.
  • GraalVM adds ahead-of-time compilation to a native binary, trading away some dynamic features for near-instant startup.

For everyday work the practical advice is short: pick any current LTS build from a maintained distribution. The differences rarely affect application code.

Common misreadings

  • "I will install the JVM." You cannot. It ships inside a JRE or a JDK and is not distributed on its own.
  • "The JDK and the JRE are alternatives." They are nested. Installing a JDK already gives you everything a JRE has.
  • "The JRE is just the JVM." The class library is the larger part of it. Without java.util nothing useful would run.
  • "A JDK is heavier so it is slower." Startup and throughput come from the JVM, which is identical in both. Only disk size differs.

Quick recall

Everything you need if you only revisit this box.

  • The nesting is JDK ⊃ JRE ⊃ JVM: development tools wrap a runtime, which wraps the execution engine.
  • The JVM executes bytecode and manages memory. The JRE adds the standard library. The JDK adds javac, jar, javadoc, jdb and jshell.
  • Compiling needs a JDK; running a finished build only needs a runtime.
  • java -version works on both. javac -version is the test for a JDK.
  • Oracle stopped shipping a standalone JRE after Java 11; use jlink to build a minimal runtime instead.
  • The JVM is a specification with many implementations — HotSpot, OpenJDK builds, GraalVM — all consuming identical bytecode.

Test yourself

Answer these before moving on — recall is what makes it stick.