Skip to content
Veltoryx Technologies
FreeLesson 1.2Beginner3 min readUpdated 30 October 2026

JDK, JRE and JVM: how Java code runs

The three names every Java developer must know, what each one does, and the path your code takes from a .java file to a running program.

You write Java in a text file. Your computer can't run that text directly. Three tools work together to turn it into a running program: the JDK, the JRE and the JVM. Let's meet them one at a time.

01The short version

  • JVM (Java Virtual Machine): the engine that runs Java programs.
  • JRE (Java Runtime Environment): the JVM plus the standard libraries a program needs to run.
  • JDK (Java Development Kit): the JRE plus the tools you need to build programs, such as the compiler javac.

Think of it like a kitchen. The JVM is the stove, the JRE is the stove with pots and ingredients, and the JDK is the whole kitchen, including the knives and recipe book you need to cook something new.

02From your code to a running program

Java code goes through two steps before it runs:

  1. Compile: the compiler javac turns your .java file into bytecode, saved in a .class file. Bytecode isn't machine code for any real processor. It's a simple, portable instruction set for the JVM.
  2. Run: the java command starts a JVM, which loads the .class file and runs the bytecode.
How Java code runs: Hello.java is compiled by javac into Hello.class bytecode, which the JVM runs on Windows, macOS or Linux
Fig. 1 · How Java code runs: Hello.java is compiled by javac into Hello.class bytecode, which the JVM runs on Windows, macOS or Linux

In the terminal it looks like this:

Terminal
javac Hello.java   # compile: creates Hello.class
java Hello         # run: the JVM runs the bytecode
Expected output
Hello, Java!

03Write once, run anywhere

Because javac produces bytecode and not machine code, the same .class file runs on Windows, macOS and Linux. Each operating system has its own JVM that understands the same bytecode. This idea is called "write once, run anywhere", and it's one of the main reasons Java became popular.

04Is Java compiled or interpreted?

Both. The code is compiled to bytecode first. Then the JVM starts by interpreting the bytecode, and, while the program runs, its JIT compiler (Just-In-Time) turns the parts that run most often into fast native machine code. That's why long-running Java programs get faster after they warm up.

05In the interview

Common follow-up questions:

  • Why is Java platform independent? Because javac produces bytecode, and every operating system has a JVM that runs the same bytecode.
  • Is the JVM platform independent? No. There's a different JVM for each operating system, and that's what lets bytecode stay the same.
  • What does the JIT compiler do? It compiles frequently used bytecode into native machine code while the program runs, so hot code runs much faster.

06Check your understanding

Quiz · 4 questions

0 of 4 answered

  1. 1. Which one do you install to write and compile Java programs?

  2. 2. What does javac produce from Hello.java?

  3. 3. Why can the same Hello.class run on Windows and Linux?

  4. 4. What makes a long-running Java program faster over time?