Home Post Core Java

What is differences between JDK, JVM and JRE ?

Mar 31, 2024

What is JDK?

Java development kit (JDK) is a cross-platformed software development environment that provides the required tools for developing, testing, and running software applications written in the Java programming language.

It consists of the Java Runtime Environment (JRE), an interpreter/loader (Java), a compiler (javac), an archiver (jar), a document generator (Javadoc), and other tools.

In general, the JDK is an implementation of one of the three Java Platforms, i.e., Standard Edition (Java SE), Java Enterprise Edition (Java EE) and Micro Edition (Java ME).

Some of the most popular JDKs are - Oracle JDK, OpenJDK, Azul Systems Zing, IBM J9 JDK and Amazon Corretto.

What is JRE?

The Java Runtime Environment (JRE), is a software layer that runs on top of a computer's operating system and provides the resources that a specific Java program needs to run.

The JRE is one of the interrelated components in the Java Development Kit (JDK) and consists of libraries, tools, a separate JVM, and other resources.

Java source code is compiled and converted to Java bytecode.

In order to run this bytecode on any platform, the appropriate JRE should be installed on that platform (OS).

In general, a JRE includes components like - JDBC, JNDI, Interface Definition Language (IDL), RMI, Scripting and other integration libraries.

What is JVM?

The Java Virtual Machine (JVM) is a engine that provides a runtime environment to drive Java code or applications.

It is a part of the JRE and is the one that actually calls the main method present in a Java program.

It converts Java bytecode into machine language.

A program (code) can be developed on one system and run on any other Java enabled system without any adjustment. This is possible because of the JVM(Java Virtual Machine).

The ClassLoader performs three major functions - Loading, Linking, and Initialization. It reads the ".class" file, generate the corresponding binary data and save it in the method area.

The method area is memory where the class is loaded and, along with that, static variables and constants are defined.

Stack is the memory area where a method is loaded and its execution takes place. All local variables are also stored here.

The heap is the memory where objects and their related instance variables are created. This memory is common and is shared across multiple threads.

The PC register stores the address of the JVM instruction that is currently executing. In Java, each thread has its own PC register.

The JIT compiler compiles the bytecodes into native code for the platform on which it is running.

avatar

NK Chauhan

NK Chauhan is a Principal Software Engineer with one of the biggest E Commerce company in the World.

Chauhan has around 12 Yrs of experience with a focus on JVM based technologies and Big Data.

His hobbies include playing Cricket, Video Games and hanging with friends.

Categories
Spring Framework
Microservices
BigData
Core Java
Java Concurrency