JDK, JRE and JVM
10 min · Beginner
Need help? Ask a tutor on WhatsApp (opens in a new tab)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
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 outputjavac builds. java runs.
What this code does
javacis the compiler, a tool in the JDK. It turnsHello.javainto bytecode:Hello.class.javastarts 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).
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.
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.
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.
Next step
Check your understanding
5 quick questions