you will learn about JVM, JRE, and JDK in Java and how they work together while we are working on any Java application.
JVM, JRE, and JDK are part of the java ecosystem to develop and run your Java application. In this lesson we will take a look at JRE JVM and JDK In Java. Java is a programming language and also a computing platform that was first released by the Sun Microsystems in the year 1995. It has since grown into the most used technology all over the world. It is the most sought technology for building Enterprise Applications. Java provides a reliable platform which helps in building many services, applications and end-to-end softwares.
Java is a free to download and use for personal use. It is a general-purpose, class-based, object-oriented programming language that has lesser implementation dependencies. James Gosling developed the Java Platform at Sun Microsystems. Now it is basically acquired and maintained by Oracle. Java is a feature-rich language. Following are some of the notable features:
JVM, also known as the Java Virtual Machine, is an abstract machine that provides a Runtime environment for executing the Java byte-code. It converts the Java byte-code into machine language. JVM is part of the Java Runtime Environment (JRE).
It calls the main method present in the Java code to actually run the application. Java applications are called as WORA (Write Once Run Anywhere). This means a programmer can basically write this code on any system and can expect it to run on any other system. The only prerequisite for running this code will be to install Java on that system. This is possible with the help of JVM only.
On compiling a
.java file, it generates a
.class file(containing the byte-code) with the same class name. This .
class file goes into various steps and then runs the actual application. Components of JVM are.
Here is an overview of the JVM working:
A JRE is a Java Runtime Environment that contains a set of components to execute a Java application. JRE is part of the JDK. JRE comprises Java Virtual Machine(JVM), Java class libraries and the Java class loader. Any software needs an environment to run the application on the Operating System(OS). JRE acts as a translator for running the program between the Java programs and the OS. JRE combines the Java code that was created using the JDK with the libraries and then runs it on the JVM. JRE acts as a high level layer on the top of the operating system.
Core components of JRE include:
Also, the JVM makes Java portable and easy to integrate. All the Operating Systems having different JVM. But regardless of the JVM versions, it will produce the same output after the execution of the byte code across all the operating systems.
JDK, also known as the Java Development Kit, is a cross-platform software development environment. It provides a collection of tools and libraries that are necessary for developing the Java-based software application. JDK provides the core package that is used in Java along with the JVM and the JRE. If someone wants to only run an application, we can achieve easily it by installing JRE on your system. Though you would require the complete java kit, i.e. JDK, for developing Java-based software applications. The code developed using JDK is executed in the JRE and JVM.
Core components of JDK include:
The JVM, JRE and JDK are not interconnected. Basically, JRE is part of JDK and JVM is part of JRE. On installing JRE in the system, we can run a Java program but we cannot compile it. We developed applications using JDK. JRE executes these applications using the JVM and Native Libraries. JVM is the one that converts the Java code into the native byte code and runs it on the system. The below diagram clearly depicts the relationship between JVM, JRE and JDK.
Let’s inspect the distinct features of JVM, JRE and JDK.
All three are core part of Java eco-system, however there are few differences between JVM, JRE and JDK, which we should keep in mind.
In the above article, we explored about the difference between JVM, JRE and JDK. We described how JVM works as an abstract computing machine which actually executes the Java byte code with the help of Just-In-Time Compiler (JIT). Then we looked into JRE and how it helps in running the Java applications.Finally we understood how to develop the Java applications with the help of Java development kit (JDK). As always, you can find the updated source code in our GitHub Repository.