JDK and JRE: What's the Difference? Breaking Down a Popular Beginner Question

Online Python Trainer for Beginners

Learn Python easily without overwhelming theory. Solve practical tasks with automatic checking, get hints in Russian, and write code directly in your browser — no installation required.

Start Course

JDK or JRE: What Should a Beginner Choose? Let's Settle This Once and For All



If you're just starting your journey in the world of Java, sooner or later you'll face the question: "So, what exactly do I need to download? JDK, JRE, or maybe just JVM is enough?". This question is so popular that on Stack Overflow it has gathered thousands of views and dozens of answers. And this is no coincidence — confusion between these abbreviations can ruin your first project before it even starts.



Imagine that Java is a kitchen. JRE is a ready-made restaurant where you can come and eat. And JDK is the kitchen itself with stoves, knives, and cookbooks, where you can cook anything. Do you see the difference? Let's break it all down so you never have to doubt what to download again.



The Basics in a Nutshell: JVM, JRE, JDK



Before diving into details, let's understand the basic hierarchy. Many beginners think these are three different products. In reality, it's like a nesting doll, where one component is contained within another.



  • JVM (Java Virtual Machine) — is the heart. A virtual machine that executes bytecode. By itself, it's as useless as an engine without a car.
  • JRE (Java Runtime Environment) — is JVM + a set of standard libraries (e.g., java.lang, java.util). This is the environment for running ready-made Java programs.
  • JDK (Java Development Kit) — is JRE + developer tools: the javac compiler, the jdb debugger, the javadoc utility, and others.


A simple formula to remember:



JDK = JRE + Development ToolsJRE = JVM + Libraries


Now, when you see the line "Download JDK" on the Oracle website, you know it contains everything you need for both running and writing code.



Why Do You Need JRE if JDK Exists?



Good question. If JDK includes JRE, why would anyone download "just the runtime environment"? It comes down to size and target audience.



Imagine you've written a super game in Java and want to let a friend play it. Your friend is not a programmer. They don't intend to compile anything. They only need a "box" to run the .jar file. Dragging the entire JDK, which is about 300 MB, to them is pointless. JRE takes up less space (around 100-150 MB) and doesn't contain extra tools that would confuse an ordinary user.



That's why on websites for downloading Java, ordinary users are offered JRE. And developers are offered JDK. In recent versions (Java 11+), Oracle went even further and essentially merged them, making JDK a "self-sufficient" module. But conceptually, the difference remains.



How to Check What You Have Installed?



The easiest way is to open a terminal (command line) and enter a couple of commands. This will save you hours of Googling when something goes wrong.



Step 1. Check the Java version (JRE):



java -version


If JRE is installed, you'll see something like:



java version "17.0.2" 2022-01-18 LTSJava(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)


Step 2. Check the compiler (JDK):



javac -version


If you see:



javac 17.0.2


Congratulations! You have JDK installed. If the command is not found, you either have only JRE, or Java is not set in the environment variables (PATH).



A Real-Life Example: Why You Can't Write Code Without JDK



Let's imagine a situation. You installed only JRE (for example, to play Minecraft). You open Notepad and write your first "Hello, World!":



public class HelloWorld {    public static void main(String[] args) {        System.out.println("Hello, world!");    }}


You save the file as HelloWorld.java.

Blogs

Book Recommendations