Skip to lesson

JDK, JRE and JVM are three short names you will see often. Together they are the parts of Java that build your program and run it.

What each one does

In What is Java? (opens in a new tab) the compiler made bytecode and the JVM ran it. JDK, JRE and JVM are the names of the parts that do these jobs.

Example · From source file to running program

Text
Hello.java     source code: the text you write    |  javac   (compiler, a JDK tool)    vHello.class    bytecode    |  java    (starts the JVM, which uses the libraries)    vThe program runs and prints its output
In short
javac builds. java runs.

What this code does

  • javac is the compiler, a tool in the JDK. It turns Hello.java into bytecode: Hello.class.
  • java starts the JVM (Java Virtual Machine), which executes the bytecode on your computer.
  • The JVM uses Java's libraries: ready-made code such as System.out.println. JVM + libraries = the JRE (Java Runtime Environment), what you need to run a program.
  • You type these two commands yourself in Your first Java program (opens in a new tab).

So the JDK (Java Development Kit) = tools such as javac + the runtime. It can build and run programs. The JRE is a name for the runtime; it is not always a separate install.

An everyday picture: a video studio

Think of a video. An editor makes the video file once; then anyone with a video player can watch it. Your .java file is the raw footage, the bytecode is the finished video file, and running the program is playing it.

  • JVM = the player. It does the actual playing (running).
  • JRE = the player plus its codecs (the libraries). Enough to play any finished video.
  • JDK = the full studio. Everything in the JRE, plus the editing tools to make new videos (the compiler).
No picture is perfect. Remember the main idea: the JDK builds your program, the JVM runs it.

How they fit together (a simple model)

Picture boxes inside boxes: the JDK holds the runtime (the JRE), and the runtime holds the JVM. This is a model to help you think, not how the files sit on your disk.

Boxes inside boxes: the JDK holds javac, other tools and the JRE; the JRE holds the libraries and the JVM, which runs bytecode.

Modern JDKs do not install a separate JRE: the runtime parts are inside the JDK. One JDK install gives you the compiler, the libraries and the JVM.

In one line: JDK = tools like javac + the runtime, and the runtime (JRE) = libraries + JVM.

Which one do you install?

Install the JDK: you need javac to build your programs, and the JDK can also run them. Since Java 11, Oracle offers only the JDK. Some providers still offer a separate JRE, but you do not need it.

You install the JDK in the next lesson: Install Java (JDK) (opens in a new tab).

Next step

Check your understanding

5 quick questions