Java Fundamentals

What Is Java? JDK, JRE & the JVM

15 min Lesson 1 of 14

What Is Java? JDK, JRE & the JVM

Java is one of the most widely used programming languages in the world. It runs everywhere — from Android phones to enterprise back-end servers, from embedded devices to cloud platforms. Before you write a single line of code, it helps to understand why Java was designed the way it was and how its three key components — the JDK, the JRE, and the JVM — work together.

A Brief History

Java was created by James Gosling and his team at Sun Microsystems in 1995. The original motivation was surprisingly practical: consumer electronics — TV set-top boxes, PDAs — ran on many different CPU architectures. Writing separate programs for each chip was expensive. The team needed a language whose compiled output could run on any device without recompilation.

Sun launched Java with the famous slogan "Write Once, Run Anywhere" (WORA). That promise is still at the heart of Java today, now maintained by Oracle and the OpenJDK community.

Java releases today: Since Java 9 (2017) Oracle ships a new version every six months. Long-Term Support (LTS) releases — Java 11, 17, and 21 — are the ones used in production. This course uses Java 17 syntax throughout.

Write Once, Run Anywhere — How Does It Work?

Most compiled languages (C, C++) translate your source code directly into machine code — binary instructions that only a specific CPU family understands. That means you must recompile for every platform you target.

Java takes a different approach. The compiler does not produce machine code. Instead it produces bytecode — a compact, platform-neutral set of instructions stored in .class files. Bytecode is not executable on any real CPU. It is a kind of recipe that a special program — the Java Virtual Machine (JVM) — interprets and executes at runtime.

Because the JVM is available for Windows, macOS, Linux, and hundreds of other platforms, the same .class file runs unchanged everywhere:

// Hello.java — source code you write public class Hello { public static void main(String[] args) { System.out.println("Hello, Java!"); } }
// Step 1: compile to bytecode javac Hello.java // produces Hello.class // Step 2: run on the JVM java Hello // prints: Hello, Java!

The javac compiler reads your .java source and writes a .class file. The java launcher loads that .class file into the JVM and executes it. You never touch machine code yourself.

Bytecode is not slow. Modern JVMs include a Just-In-Time (JIT) compiler that watches which parts of your program run most often and compiles those hot paths directly to native machine code at runtime. Java programs often reach performance close to C++.

The Three Layers: JVM, JRE, and JDK

These three acronyms confuse almost every beginner. Think of them as concentric circles — each one contains the previous.

1 — JVM: Java Virtual Machine

The JVM is the engine that executes bytecode. It is responsible for:

  • Loading .class files via the ClassLoader.
  • Verifying bytecode for safety (no illegal memory access).
  • Executing instructions — either by interpreting them or compiling them to native code (JIT).
  • Managing memory through garbage collection — automatically freeing objects you no longer need.

The JVM itself is platform-specific (there is a separate JVM binary for Windows, Linux, macOS), but the bytecode it runs is universal.

2 — JRE: Java Runtime Environment

The JRE is the JVM plus the standard class library — the thousands of built-in classes that ship with Java (java.lang, java.util, java.io, and so on). If someone only needs to run a Java application (not build one), they install the JRE.

JRE as a separate download was retired in Java 11. Oracle and OpenJDK distributions no longer ship a standalone JRE. You install a JDK and use the jlink tool to bundle a minimal runtime into your application if needed. In practice, developers always install the JDK.

3 — JDK: Java Development Kit

The JDK is everything in the JRE plus the development tools:

  • javac — the compiler that turns .java source into .class bytecode.
  • java — the launcher that starts the JVM.
  • javadoc — generates HTML documentation from specially formatted comments.
  • jar — packages .class files into a single archive.
  • jshell — an interactive REPL for experimenting with Java snippets.
  • Debugger, profiler, and many other utilities.

As a developer, you always install the JDK. End-users who only run your application used to need only the JRE, but as noted above, modern distributions bundle a JRE inside every JDK.

Visualising the Relationship

┌─────────────────────────────────┐ │ JDK │ │ javac, jar, javadoc, jshell … │ │ ┌───────────────────────────┐ │ │ │ JRE │ │ │ │ Standard Class Library │ │ │ │ ┌─────────────────────┐ │ │ │ │ │ JVM │ │ │ │ │ │ ClassLoader JIT │ │ │ │ │ │ GC Bytecode Eng. │ │ │ │ │ └─────────────────────┘ │ │ │ └───────────────────────────┘ │ └─────────────────────────────────┘

Why This Matters for You as a Developer

Understanding these three layers explains several things you will encounter constantly:

  • When a colleague says "make sure the right Java version is on the PATH", they mean the JDK's bin/ folder where javac and java live.
  • When a Docker image says FROM eclipse-temurin:17-jre, it contains only a JRE — enough to run a compiled app but not to build one.
  • When your IDE underlines a missing import, it is the JRE's class library that provides those types.
  • When a program throws an OutOfMemoryError, it is the JVM's garbage collector that ran out of heap space.
Version mismatches cause subtle bugs. If you compile with JDK 17 but run on a JVM from Java 11, you will get a UnsupportedClassVersionError at startup. Always ensure your compile target (--release flag) matches the JVM version in production.

Summary

Java achieves write-once-run-anywhere by compiling source code to platform-neutral bytecode, which the JVM executes on any supported OS. The JRE bundles the JVM with the standard library. The JDK adds the developer tools — most importantly javac — on top of the JRE. In the next lesson you will install a JDK and write, compile, and run your first Java program.