JDK, JRE, and JVM

Mohit Sharma
2 min readApr 2, 2022

--

When we start learning Java, this triple j is a commonly used term and is very confusing. In this post, I will try to explain to you in a very simple way.

To start java, First, we need to install JDK (Java Development Kit). When the installation is done we don’t need to install JRE and JVM separately. They are already installed with JDK.

JDK is a tool kit that has various development (developing Java programs) tools such as compiler (javac), debugger (jdb), etc, JRE (Java Runtime Environment) and JVM(Java Virtual Machine). You can see all the development tools in the bin folder.

So let’s start with an example and see the usage of JDK, JRE & JVM.

Write a simple Hello World program in notepad. Once you have written your Hello World program you need a JDK development tool to compile it which is javac. This javac compiles your code and converts it into bytes code.

Now you need an environment to execute the byte code. JVM (Java Virtual Machine) plays an important role here. JVM is a part of JRE which is used to execute the java program after compilation.

Commands:
javac HelloWorld.java (compile the code)
java HelloWorld (execute the code)

`javac` is a compiler and, `java` is a run time environment that creates the environment to execute the java program. `java` is part of the JDK development tool but we specifically call it JRE that is internally having JVM.

Note: we can say that after compiling the code, Java programs run inside JRE, and Java programs are actually being executed by JVM.

--

--