JVM , JRE & JDK – Understand & Differentiate in Simple Words

This is a frequently asked interview question of Java because people always gets confused with these terms and used interchangeably. I will try to explain these terms in easy words.

There are three stages for writing a code in any programming language – Development , Compilation and Execution. In Java programming language, there are three major components –

JDK – Java Development Kit

JRE – Java Runtime Environment

JVM – Java Virtual Machine

JVM is an internal part of JRE and JRE is an internal part of JDK. If you want to develop and execute a Java program – You need JDK. When we say JDK, it means you indirectly required JRE and JVM. You want to just execute a java program – You need only JRE.

JVM –

  1. It is an abstract (Virtual) machine which loads, verifies, and executes bytecode (.class file).
  2. After compiling a .java file, we gets .class file that is called bytecode.
  3. JVM converts this bytecode to machine readable code based on platform.
  4. This is the reason JVM is platform dependent which makes Java a platform independent language.
  5. It contains many blocks – Class Loader, Memory Areas, Execution Engine Interpreter and JIT compiler.
  6. The JVM is called a virtual machine because the JVM definition defines an abstract machine. This includes registers, stack, etc, and the byte code that Java source is compiled to is practically machine code for this virtual machine. The JVM then interprets or compiles this bytecode into native machine instructions.
  7. We can find JVM as .dll file( in windows) and .so(in Linux) . Below is screenshot of JVM in windows:
  8. It resides inside JRE.

JRE –

  1. It consists of JVM and many software packages (Supported classes to run Java programs, Property files etc.) which help JVM to perform its tasks.
  2. JRE is available outside of JDK as well. If you just want to execute .class file, you need JRE only.
  3. JRE is responsible for providing a runtime environment only. This is the reason it does not contain any development tools like compiler and debugger.
  4. JRE is platform dependent which makes Java a platform independent language.
  5. In below image, you can see JRE contains bin ( JVM ) and supported libs.

JDK –

  1. JDK consists of development tools and run time environment (JRE).
  2. If you want to develop and run a java program, you need a JDK.
  3. It is a kit or complete package to develop, compile and execute a Java program. It means that it contains JRE and JRE contains JVM. This is the reason it is called as a Kit.
  4. It is also platform dependent which makes Java a platform independent language.
  5. When we download JDK, you can see it consists JRE in it .

Below image will give you better understanding:

Hope, it will be easy for you now to differentiate among JVM, JRE and JDK. I will suggest you to remember in same flow i.e. JVM, JRE and JDK.

In case of any doubt, suggestion or you find some mistake, feel free to let me know in comments.

#ThanksForReading

#DonateIfYouThinkMyPostsHelpYou

2 thoughts on “JVM , JRE & JDK – Understand & Differentiate in Simple Words

  1. “JRE is available outside of JDK as well. If you just want to execute .class file, you need JRE only.”

    Can you explain this line a little more. i am little confuse between JRE and JVM.

    Java compiler converts .java code to .class file

    JVM converts the bytecode .class file to machine code(.dll)

    so what does JRE actually does.

Leave a Reply

Your email address will not be published. Required fields are marked *