Difference between JRE, JDK, and JVM in Java?

We all ask questions when we are learning something. Good programmers never accept things directly, they always ask questions and understand deeply how the system exactly works. It always gives you more confidence if you know the system’s internal workings and understands each and every part of the code.

So now when I started learning java, the first thing I downloaded was JDK. In a fraction of a second, my mind asked me, “Bro did you know what is JDK?” and that was the second when this journey started. Let’s take a look at what is JDK, JRE, and JVM, and how they work?

JVM (Java Virtual Machine)

JVM simply helps to execute programs on your device. It provides an environment to run the programs.

Below are four main tasks of JVM:

  1. Loads the code
  2. Verifies the code
  3. Executes the code
  4. Provides runtime environment

Without JVM you cannot run the JVM-based programs.

JDK, JRE, and JVM Dev Headquarter
JDK, JRE, and JVM Dev Headquarter

JVM is platform-dependent. That means we have different JVM configurations for each software and hardware platform. That means the JVM which is run on macOS will not run on windows, for windows you have to download the Windows version of the JVM.

JRE (Java Runtime Environment)

Whenever we try to run the code, JVM requires some library sets and files for code execution, and these files are presented in JRE.

JRE = JVM + set of libraries

So to run the JVM-based programs, the JRE is a minimum requirement.

JRE is also platform dependent. That means we have different JRE versions for different platforms.

JDK (Java Development Kit)

JDK is a full-featured development kit. It has each and every development tool that you may require for creating robust java programs.

JDK = JRE + Development tools.

Java Development Kit contains the following tools:

  1. Java Runtime Environment (JRE)
  2. Interpreter
  3. Compiler (javac)
  4. Archiver (jar)
  5. Documentation generator (javadoc)
  6. Some other necessary tools

So in short, if you just want to run the java or JVM-based code then JRE is required. But to develop java programs then JDK is required.

Related articles