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:
- Loads the code
- Verifies the code
- Executes the code
- Provides runtime environment
Without JVM you cannot run the JVM-based programs.
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:
- Java Runtime Environment (JRE)
- Compiler (javac)
- Archiver (jar)
- Documentation generator (javadoc)
- 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.