Provide Best Programming Tutorials

Relationship between JVM,JRE,JDK

Overview

This article will talk about JVM, JDK, and JRE.

Generally speaking, if you just wanna run the java program simply install JRE is ok but if you wanna develop the java program you need to install JDK instead.

As of JVM, you can imagine it as the engine for both JRE & JDK.

So let’s explain them in depth one by one.

Java Virtual Machine (JVM)

This is generally referred as JVM. Before, we discuss about JVM lets see the phases of program execution.

For more detail about JVM please refer to JVM Tutorial

Phases are as follows:

  1. Writing of the program is of course done by java programmer like you and me.

  2. Compilation of program is done by javac compiler, javac is the primary java compiler included in java development kit (JDK). It takes java program as input and generates java bytecode as output.

  3. In third phase, JVM executes the bytecode generated by compiler. This is called program run phase.

So, now that we understood that the primary function of JVM is to execute the bytecode produced by compiler. Each operating system has different JVM, however the output they produce after execution of bytecode is same across all operating systems. That is why we call java as platform independent language.

Bytecode

As discussed above, javac compiler of JDK compiles the java source code into bytecode so that it can be executed by JVM. The bytecode is saved in a .class file by compiler.

Java Development Kit(JDK)

While explaining JVM and bytecode, I have used the term JDK. Let’s discuss about it. As the name suggests this is complete java development kit that includes JRE (Java Runtime Environment), compilers and various tools like JavaDoc, Java debugger etc. In order to create, compile and run Java program you would need JDK installed on your computer.

Java Runtime Environment(JRE)

JRE is a part of JDK which means that JDK includes JRE. When you have JRE installed on your system, you can run a java program however you won’t be able to compile it. JRE includes JVM, browser plugins and applets support. When you only need to run a java program on your computer, you would only need JRE.

These are the basic java terms that confuses beginners in java. For complete java glossary refer this Link.

Below is the realtionship between JDK&JRE&JVM

Leave a Reply

Close Menu