Skip to main content

JVM, JRE and JDK in Java

JVM, JRE and JDK are the most basic common concepts to know in java. These are the basic features to understand how Java architecture works? JVM stands for Java Virtual Machine, which doesn't have any physical directories created in java installation. JRE stands for Java Runtime Environment, which creates the directory under Java installation path and also present in JDK. JDK stands for Java Development Kit, which creates the directory in Java installation path and also it has it's own JRE. Since we have already learn that Java is platform independent means if we have implemented any of the java class in one environment, it will be executed in any other environment and provides the same output. But, JVM, JRE and JDK all are platform dependent. So that, for windows, linux, unix, mac, solaris..etc has it's own JVM, JRE and JDK. One will be not compatible with other environments.

While installing the Java, we might come to know a bit about JRE and JDK. But, JVM is the other concept which need to be understand very clearly before digging into the Java programming. There are many things which we need to learn as part of JVM, like, class loaders, JIT-Compiler, Memory areas, etc.

JVM - Java Virtual Machine:
Java Virtual Machine is the heart of entire Java program execution process. It is responsible for taking the .class file and converting each byte code instruction into the machine language instructions that can be executed by the microprocessor.

The above diagram represents the architecture of Java Virtual Machine. Here are the few points to understand about the JVM Architecture.
  • The .java program converted into .class file consisting of byte code instructions by the java compiler. Java compiler is outside the JVM. Now, .class file is given to the JVM, there is a module called Class Loader Subsystem.
    • Class Loader Sub System loads the .class file into memory.
    • It verifies all byte code instructions are proper or not. If it finds any instruction suspicious, the execution is rejected immediately.
    • If the byte code instructions are proper, then it allocates necessary memory to execute the program.
    • This memory is divided into 5 parts, called Runtime data areas, which contains the data and results while running the program.
      • Method area: Method area is the memory block, which stores the class code, code of the variables and code of the methods in the java program.
      • Heap: Heap is the area where objects are created. Whenever JVM loads a class, a method and a heap area are immediately created in it.
      • Java Stack: Method code is store in method area. But, while running a method, it need some more memory to store data and results. This memory is called on Java Stack.
      • PC (Program Counter) Registers: These are the registers which contains the memory addresses of the instructions of the methods. If there are 3 methods, 3 PC registers will be used to track the instructions of the methods.
      • Native method: Java methods are executed on Java Stacks. Similarly, native methods (Ex, C/C++ functions) are executed on Native method stacks.
  • Execution engine contains interpreter and JIT (Just-In-Time) Compiler, which are responsible for converting the byte code into machine code so that the processor will execute them. In any other technologies like C, C++, Fortan..etc will use either interpreter or a compiler. But, in Java will use interpreter and JIT compiler both at the same time.
  • After loading .class into the memory, JVM will decide which code is to be left to interpreter and which one to JIT Compiler so that the performance is better.
Class Loaders:
When we generate the .class file from .java file, class loaders will be used to load the .class file. There are 3 different types of class loaders in java.
  1. Bootstrap Class Loader: This is used to load the JDK internal classes, typically rt.jar and other core java classes.
  2. Extension Class Loader: This is used to load classes from ext/extension directory from JAVA installation directory. Ex: C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext
  3. System Class Loader: This loads classes from current class path that can be set while invoking program either using -cp or -classpath command line. It will also set from project build path from eclipse or other IDE's.
Java Runtime Environment:
Java Runtime Environment (JRE) contains a set of software's to run Java application and it also includes the Java Virtual Machine (JVM) and platform supporting libraries. JRE is part of the JDK otherwise we can specially get and install JRE separately.

Java Development Kit:
Java Development Kit contains set of software's to develop Java application. It has it's own Runtime Environment also known as JRE so no need to install separately. JDK includes java development libraries along with JRE. Since, JRE it has it's own JVM that mean JDK has the both of JRE and JVM in it.



Comments

  1. Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time.

    Digital Marketing Training in Chennai

    Digital Marketing Course in Chennai

    ReplyDelete
  2. Thanks for the blog article.Thanks Again. Keep writing.
    java training
    java online training

    ReplyDelete
  3. It is an excellent blog Thank you for providing important information and I am searching for same information, Thank you for sharing good content.
    sap fico training in Marathahalli

    ReplyDelete
  4. I am so grateful for your blog. I am really looking forward to reading more really is is a wondarfull Blog.
    sap mm training in btm layout

    ReplyDelete
  5. Softlogic is No:1 Software Training Institute in Chennai offers best IT Training Courses for Java, Android, PHP, .NET, DevOps, Oracle with 100% placements.

    Data Science Training in Chennai
    python data science course in Chennai

    ReplyDelete

Post a Comment

Popular posts from this blog

Multithreading in java with example

Multithreading  is one of the most important concept in core java. In this article we will learn what is multithreading? , what is the use of it? and What is the use of Synchronization and when to use it?  with detailed examples. At a time, two or more threads are accessing the same object is called as Multithreading  in Java .  First, we will create two threads for two objects. It is also possible to run two or more threads on a single class object. In this case, there is a possibility to get unreliable results. If the two threads are perform same task, then they need same object to be executed each time. For your better understanding, take an example of any reservations like, railway, movie ticket booking,etc. Let us think only one berth is available in a train and two passengers are asking for that berth. The first person has sent a request to allocate that ticket/berth to him. At the same time, the second person also sent a request to allocate that ...

Git installation for AngularJS 2 in Windows 10

Download Git latest version from https://git-scm.com/downloads or you click on the below link to download directly for windows https://git-scm.com/download/win . Once download completes, click on executable file to start installation process and choose Yes to allow the software installation in windows 10. Click on Next button to continue further installation. Browse the isntallation directory and click on Next button to continue. Select the list of components which you want to be installed and click on Next button to proced further installation. Type the shortcut name for Start menu and click on Next button. Select how you want to use the Git and click on Next button. For Windows no need to change anything, let it be the default one. Choose the Use the OpenSSL library and click on Next button. Select how should Git treat line ending in text files and click on Next button. Select which terminal emulator to use with Git and click on Next button. Configure extr...

JNDI configuration for Tomcat 9 with Oracle

In this article, I am going to place the required source code to get data from the table by using the JNDI configuration. Below are the environment details that I have configured currently. Windows - 7 Oracle - 10g Tomcat - 9 JDK - 8 Eclipse Oxygen Ojdbc6 jar required First, we need to create the Dynamic Web Project. If you don't know how to do <Click Here>. I have faced a lot of issues before getting the output like 405, No driver class to load, etc. I am using JSP & Servlets in the current explanation. Before started writing the application logic, we need to do the below configuration in the installed tomcat directory. Place OJDBC6.jar in the Tomcat LIB directory. Add this Resource under <GlobalNamingResources> in Server.xml file which is present under the conf directory in Tomcat. < Resource name = "jdbc/myoracle" global= "jdbc/myoracle" auth = "Container" type= "javax.sql.DataSource" driverClass...