Java JVM, JRE and JDK Explained with Diagrams

In this chapter, we will discuss an important definition of JVM, JRE, and JDK in the Java programming language. We also discuss the difference between JVM, JRE, and JDK.

Java technology is both a programming language and a platform. The Java programming language is a high-level object-oriented language that has a particular syntax and style. A Java platform is a particular environment in which Java programming language applications run.

Let's start with what is JVM?

1. JVM (Java Virtual Machine)

The Java Virtual Machine is a program, for a particular hardware and software platform, that runs Java technology applications. In simple terms, the Java Virtual Machine (JVM) is the virtual machine that runs the Java bytecodes.

When you run the Java program, the Java compiler first compiles your Java code to bytecode. Then, the JVM translates bytecode into native machine code (set of instructions that a computer's CPU executes directly).

JVM translates the byte-code into machine language, and since the machine language depends on the operating system being used, it is clear that the JVM is platform (operating system) dependent.

If you are interested in learning about JVM Architecture, visit The JVM Architecture Explained.

2. JRE(Java Runtime Environment)

The Java Runtime Environment (JRE) provides the libraries, the Java Virtual Machine, and other components to run applets and applications written in the Java programming language.

The below diagram shows the JRE (Java Runtime Environment) is a software package that provides Java class libraries, along with Java Virtual Machine (JVM), and other components to run applications written in Java programming.

JRE = JVM + Java Packages Classes (like util, math, lang, awt, swing etc) + runtime libraries.

3. JDK(Java Development Kit)

The JDK(Java Development Kit) is a superset of the JRE and contains everything that is in the JRE, plus tools such as the compilers and debuggers necessary for developing applets and applications.

The below diagram shows JDK (Java Development Kit) is a software development kit that contains everything that is in the JRE, plus tools such as the compilers and debuggers to develop applications in Java.

4. JDK vs JRE vs JVM 

Let’s look at some of the important differences between JDK, JRE, and JVM.
  1. JDK is for development purposes whereas JRE is for running the java programs.
  2. JDK and JRE both contain JVM so that we can run our java program.
  3. JVM is the heart of Java programming language and provides platform independence.
The below diagram shows the relationship between JVM, JRE, and JDK.


Post a comment