Difference between JRE, JDK and JVM in Java | Complete Guide
We often come across the difference between JRE, JDK and JVM when we are introduced to JAVA. However, most of us are unable to establish that clear line of difference between these terms and the vagueness and similarities in names and definitions often confuses us.
Difference between JRE, JDK and JVM in Java?
So if you are one of those people, read on to get clarification of concepts and clear that long lasting doubt from your mind.
What is Java Virtual Machine (JVM)?
First of all, let us talk about Java Virtual Machine. Before getting introduced to this term, we go through various features of Java like robustness, object-oriented, strongly typed, platform independence and so on.
Platform independence is the most important one among them, which means that once compiled, the bytecode can be executed on any machine.
But how is this achieved? How can machines with different architectures and operating systems run the same code?
This is possible because Java creates its own machine (virtual) to run on which makes it independent of other machines. This is JVM.
So what does JVM do?
JVM loads, verifies and executes code and gives the code a virtual machine or an environment to run on. It is a kind of interpreter. It also provides memory management and garbage collection functions.
What is Java Run Time Environment (JRE)?
Java Run Time Environment provides everything that is needed to run a program. It mainly includes the environment to run the program along with the set of libraries or functions that are necessary for the execution of a program.
However, JRE cannot alone help us develop a program. It is physical (not virtual) and provides us with features to simply runs them.
What is Java Development Kit (JDK)?
JDK is a kit, which means a collection of tools or a bundle of software components to compile as well as run the program.
It contains the environment to bytecode the program but also helps a programmer to develop applications. It consists of a compiler and debugger as well.
Java developement kit is an implementation of Java SE, Java EE or Java ME. We often begin with Java SE to get a grip on the basic features of Java.
So, I hope this clarifies the difference between JRE, JDK and JVM in Java.
In case there’s still a doubt, I’d share with you three simple lines that my teacher asked me to always remember which assures that I do not get confused between these terms.
JVM: Virtual Machine for platform independence
JRE: JVM + API
JDK: Compiler + JVM + API (or JRE + API)
Here, API stands for Application Programming Interface, or simply stated, a set of functionalities or a library.
We may also come across a term, Just in Time Compiler (JIT).
What is Just in Time Compiler (JIT)?
It is simply a module or component or a subset of JRE. It compiles some part the byte code into machine code along with working to improve the efficiency of the program. Rest all parts of the bytecode are interpreted and executed.
Note if you are installing Java on your system. When we are working with Java, we need to install only two packages, JDK and JRE. All other functionalities and tools are available in them itself.
You may like to read:
- If you are new to Java programming, you can read complete installation setup guide for Java. So what are you waiting for? Install JDK and start coding.
- You may come across different environment variable in Java. You can read the difference between path and classpath environment variable in Java.
Hope this is a quick guide for finding the difference between JRE, JDK and JVM and to start with Java. If you are Java developer, you can follow the Java programming sections to get updated with.