BASICS OF JAVA

What is JVM, JRE and JDK🤔

Brief on Java Core Components

Sowjanya Sunkavalli
4 min readAug 7, 2022

--

Hello everyone…🙌

Hope you guys are doing great with your learning!!!

So, in this blog lets briefly look into story of so-called Main Components of Java Programming JVM, JRE and JDK as discussed in my First Story.

If you have not read my Previous story yet why are you waiting, check it out, you will get the brief idea on How Java program is executed in a very precise way.

So, what are these terms JVM, JRE and JDK, well everyone knows this as below

JVM — Java Virtual Machine

JRE — Java Runtime Environment

JDK — Java Development Kit

To execute/run any Java based Application or Program we need the Help our above JVM, JRE and JDK components.

JDK, JRE and JVM

From the above figure we can represent JVM, JRE and JDK Mathematically as follows

JDK = JRE + JVM + Development Tools

JRE = JVM + Library Classes

So, ultimately JVM is one Component on which the entire Flow of Java Program Execution is done combined with required libraries and Development Tools.

Now, lets understand the Working model / architecture of JVM, Here goes.

What is JVM?

We called it as Java Virtual Machine, but ever wondered why it is called Virtual Machine🤔

JVM is Virtual Machine because it is a Software Implementation of Physical device i.e., whenever we write Java Program which is called WORO (Write Once and Run Anywhere), .java file is converted to .class file and finally which is given to VM i.e., our JVM to implement and produce the Output. This JVM is Platform Dependent i.e., for every OS we have specific JVM, but Java is called Platform Independent Language, do you know why?

Yes, it is because the Byte Code Produced from Compiler is Platform Independent which makes Java termed as Platform Independent.

So, what happens inside our Masterpiece JVM, for that we should have a sneak peek into JVM Architecture.

Architecture of JVM

JVM Architecture

JVM Consists of Three Main Categories, namely

Class Loader, JVM Memory and Execution Engine.

Class Loader — Class Loader is used to Load the Class File and save the Corresponding Byte Code in the Memory area.

JVM Memory — All the Memory management of the Java Program is done here.

Method Area — It will hold the class level information of all the classes in the Code. This component is shared by all the Classes.

Heap — We know that JVM creates the Class Object for each class file, this Objects are stored in the Heap Memory.

Stack — This is also kind of Memory storage component, but it will store all the temporary variables in the Code.

PC Registers — This component keeps track of which Instruction is being executed and which Instruction is going to be executed next.

Native Method Stack — It holds the information of the Native Methods, for every thread there is separate Native Method Stack will be created.

Execution Engine — It contains Interpreter and JIT Compiler which executes the Byte code and Produces the Machine-Readable Code which will finally sent to OS to execute and Produce Output according to the Logic Given.

Execution Engine also Contains Garbage Collector which removes the unreferenced Objects created by JVM.

Native Method Libraries — This component contains all the required libraries for the Program to be executed.

Native Method Interface — This component also Called as Java Native Interface (JNI), which interacts with the Native Libraries and Provides them to the Execution Engine.

There is a lot about JVM, JRE and JDK, So Let us conclude it in a nutshell.

JDK — Will have all the Required Development Tools, Java Doc etc., so when we write a Program, and Execute It will reach to JVM via JRE.

JDK Responsibilities — Providing Java Compiler, Debugger and Other Development Tools.

JRE Responsibilities — Comprises of JVM which Provides required libraries for the Java Program Execution.

JVM Responsibilities — Load class file →Memory Management →Execution of Program

So, this is all about JVM, JRE and JDK, I hope you guys liked it.

In the next story I will come up with brief idea on the Basics of Java Program Syntax.

Happy Learning everyone🙌

--

--

Sowjanya Sunkavalli

Hey there, I’m Sowjanya, a passionate Quality Assurance Engineer👩🏻‍💻🪲 who loves to write, share and learn.