Differentiate JDK JRE JVM and JIT

Here we will learn about JDK JRE JVM and JIT. What are these and where they used for Java Programs? How java achieved platform independency?

  • JDK provides an environment to develop and run Java applications.
  • JRE provides an environment just to run Java applications.
  • JVM is responsible to run the Java program line by line.
  • JIT help interpreter for executing Java byte code fastly.

JVM (Java Virtual Machine)

Java virtual machine is an abstract machine that enables our computer to run a java program.

When we run a Java program, the compiler checks the syntax of the source code file. If there is any mistake occurs then the compiler gives compile-time error otherwise it converts source code to byte code. Byte code is the native language of the Java Virtual Machine. Our operating system doesn’t understand this byte code. This byte code is only understandable by JVM. JVM translates byte code into native machine code (set of instructions that a computer’s CPU executes directly).

JVM is a Java platform because it is responsible to execute our Java byte code. It provides interpreter + JIT using which we can run Java byte code by converting them into current OS machine language. The interpreter is responsible to run a Java program line by line.

JRE (Java Runtime Environment)

Java runtime environment (JRE) is a software package that provides Java class libraries, along with Java virtual machine (JVM), and other components to run applications written in Java programming.

JRE is part of JVM. Using JRE, we can only execute already developed applications, we can not develop new applications and also we can not modify the existing applications.

JDK (Java Development Kit)

JDK stands for Java Development Kit. It is a software development kit to develop applications in Java. When we download JDK, JRE is also downloaded. In addition to JRE, JDK also contains the number of development tools (compilers, Javadoc, java Debugger e.t.c).

It contains development tools (compiler) and runtime environment (JVM). So using JDK we can develop, compile and execute new applications and also we can modify existing applications.

JIT (Just in Time)

The JIT stands for Just in Time compiler. It is responsible to help interpreter for executing Java byte code fastly. Basically JIT will improve the performance of Java program execution. It is part of hotspot technology.


The relation between JDK JRE JVM and JIT

JIT is part of JVM, whereas JVM is part of JRE, and JRE is part of JDK.

JVM = Interpreter + JIT
JRE = JVM + Library classes
JDK = JRE + Development Tools

Relation between JDK JRE JVM and JIT

Different Environments in Java

There are different environments existed in real-time projects development
1) Development environment:- Here developers will work to develop new programs. Hence we should install JDK in the development environment.
2) Testing environment:- Here testers will work to test the project, which means they just execute the project. Hence, the JRE installation is enough.
3) Production environment:- Here end-users will work to use the project, which means they just execute the project to complete their transactions. Hence JRE installation is enough.

From the Java11 version onwards JRE is not available, only JDK is used for all purposes.


Types of files available in the software

Every software has below two types of files.

Binary Files – These are command files and it is by default stored in a folder called “bin”. They have commands to be executed in sequence. Java binary files have commands to compile and execute the Java program.

binary files

Library Files – These are program files by default stored in the “lib” folder. They have logic that is used to develop another application. Java library files are used in developing new Java applications and applets.

library files

Platform Independency

Java program is not compiled and executed by the operating system (OS), rather Java program is compiled into byte code which is common to all systems. This byte code can be executed by any operating system. Byte code translated into the machine language of the operating system in which Java program is running. So, Java achieved platform independency by generating machine language for the client operating system by moving machine language generation from the compilation phase to the execution phase by introducing new compiler software, bytecode, and JVM.

Java plateform independency due to jdk jre jvm
  • Java language is platform-independent because JVM is available for every operating system. So, the Java program can be executed in all operating systems.
  • Java software (JDK) is platform-dependent because we have separate JDK for the different operating systems.

For all OS (operating systems like Windows, Linux, and e.t.c.), JVM is developed by SUN/Oracle, not by OS vendors (Companies who develop operating systems). So, JVM will not be installed inbuilt along with OS installation. We must install JVM explicitly on our computer after OS installation.

JDK dependecy

.NET program is also platform-independent. .NET programs also compiled into intermediate code to all OS, for others it is translated into current operating system machine language by CLR. Here, .NET has a problem. Microsoft gave CLR only for the windows operating system. CLR is not available for Linux, Mac OS so, the .NET program can’t be executed in these operating systems.

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or you find anything incorrect? Let us know in the comments. Thank you!

Leave a Reply