In this section, we will learn about JDK , JRE and JVM in java. We will also discuss about the importance and working of JVM in details.

You can also refer our video tutorial for same.

So let’s start with this tutorial :


JDK (Java Development Kit) :

  • JDK stands for “java development kit” . Basically JDK is a software development kit used for developing a java applications and applets.
  • It consist JRE (java runtime environment), java compiler and java application development tools.

JRE (Java Runtime Environment) :

  • JRE provides the minimum requirements for executing a java application.
  • It consists of the java virtual machine, core classes and supporting files.

JVM (Java Virtual Machine) :

  • JVM is an abstract machine. It is a specification that provides run time environment.
  • JVM are available for many hardware and software platform i.e. JVM is platform-independent.
 It is : 

1. A Specification :-

  • A specification where working of java virtual machine is specified.
  • But here, implementation provider is independent to choose the algorithm.
  • Its implementation is provided by sun and other companies.

2. An Implementation :-

  • An implementation is a computer program that meets the requirements of the JVM specification.
  • Its implementation is known as the JRE.

3. Runtime Instance

  • Whenever you write the “ java” command on the command prompt to run the java class, an runtime instance of jvm is created.

Functionality of JVM :-

  • Load java code
  • Verify the code
  • Executed the code
  • Provide runtime environment

Working of JVM :-

Class Loader :-

  • A class loader is a subsystem of JVM that is used to load the class files.
  • Classloader subsystem performs the following function:-
    • Loading
    • Linking
    • Initialization

1. Loading :-

  • It is responsible for loading those classes which is responsible for JVM function properly.
  • It is responsible for loading for classes i.e. java.lang. etc.

Path : jdk/jre/lib/RT.jar

1. Bootstrap Class Loader : –

  • It is responsible for loading those classes which is responsible for JVM function properly.
  • It is responsible for loading for classes i.e. java.lang. etc.

Path : jdk/jre/lib/RT.jar

2. Extension Class Loader :-

  • It is the child of bootstrap class loader.
  • It is responsible for the loading class from extension.

Path: jdk/jre/ext/

3. Application Class Loader :-

  • Application class loader is also known as system class loader.
  • It is responsible for loading the class from the path specified by environment variable.
  • It is also used to load an application entry point.

2. Linking :-

Perform verification, preparation and resolution.

1. Verification :-

It ensures the correctness of .class file i.e. it check whether this file is properly formatted and generated by valid compiler or not. If verification fails, we get run-time exception java.lang.VerifyError.

2. Preparation :-

JVM allocates memory for class variables and initializing the memory to default values.

3. Resolution :-

It is the process of replacing symbolic references from the type with direct references. It is done by searching into method area to locate the referenced entity.

3. Initialization :-

  • In this phase, all static variables are assigned with their values defined in the code and static block if any.
  • This is executed top to bottom in a class and from parent to child in class hierarchy.

JVM Memory :-

1. Method Area :-

  • In method area, all class level information like class name, immediate parent class name, methods and variables information etc. are stored, including static variables.
  • There is only one method area per JVM, and it is a shared resource.

2. Heap Area :-

  • Information of all objects is stored in heap area. There is also one Heap area.
  • There is only one heap area per JVM.

3. Stack Area :-

  • For every thread, JVM creates one run time stack which is stored here.
  • After a thread terminates, its runtime stack will be destroyed by JVM.

4. PC Register :-

  • Store address of current execution instruction of a thread.
  • Each thread has separate PC register.

5. Native Method Area :-

  • For every thread, separate native stack is created which store native method information.

Execution Engine :-

  • Execution engine executes class files. It read byte code line by line, use data and information present in various memory areas and execute instruction.
  • It can be classified in three parts.

1. Interpreter :-

  • It interprets the byte code line by line and then executes the code.
  • The disadvantage here is that when one method is called multiple times, every time interpreter is required.

2. Just-in Time Compiler :-

  • It is used to increase the efficiency of interpreter.
  • It compile the entire byte code and change it into the native code so whenever interpreter see repeated method calls, JIT provide direct native code for that part, so re- interpretation is not required.

3. Garbage Collector :-

It destroys unreferenced objects.

Java Native Interface :-

  • It is an interface which interacts with the native method libraries and provides native libraries (c or c++) require for the execution.
  • It enables JVM to call c/c++ libraries which may be specify to hardware.

Native Method Libraries :-

  • It is the collection of native libraries (c / c++) which are required for the execution of program.

If you found this post useful, don’t forget to share this with your friends, and if you have any query feel free to comment it in the comment section.

Thank you 🙂 Keep Learning !

Leave a Comment

Your email address will not be published. Required fields are marked *