What is the Difference Between JDK , JVM And JRE ?

JDK vs JRE vs JVM

The major difference between JDK, JRE, and JVM are shown in below table :

JDKJREJVM
The full form of JDK is Java Development Kit.JRE is Java Runtime Environment.JVM is Java Virtual Machine.
JDK is a software development kit to develop applications in Java.It provides a platform to execute java programs. JVM executes Java byte code and provides an environment for executing it.
It is a compilerBut, It doesn’t contain any development tools such as Java compiler, debugger, etc.It is an Interpreter
In short, It converts source code to byte code.JRE consists of JVM, Java binaries, and other classes to execute any program successfully.In short, It converts byte code to machine code.
JDK is platform-dependent.Likewise, JRE is also platform-dependent.But JVM is platform-independent.
Moreover, It contains tools for developing, debugging, and monitoring java code.Similarly, It contains class libraries and other supporting files that JVM requires to execute the program.But, Software development tools are not included in JVM.
It is the superset of JREIt is the subset of JDK.JVM is a subset of JRE.
The JDK enables developers to create Java programs so they can be executed and run by the JRE and JVM.The JRE is the part of Java that creates the JVM.It is the Java platform component that executes source code.
JDK comes with the installer.JRE only contains an environment so it executes source code.JVM bundled in both software JDK and JRE.
Differences between JDK vs JRE vs JVM
Workflow of JDK vs JRE vs JVM
Compilation and Execution of Java program

1 . JDK

JDK is a Java Development Kit that converts byte code into source code therefore JDK acts as a compiler. A compiler is a computer program that translates computer code from one language to another language all at once.

The command which is used for the compilation of java program can be shown from below example

javac filename.java

Meanwhile, you can download JDK for Windows/Mac/Linux from their official website.

2. Byte Code

Byte code is highly optimized code and it is platform-independent code, therefore, it can execute on various machines like Windows, Linux, etc. and it is executed by JVM(Java Virtual Machine). It is derived during the compilation of source code with the help of JDK(Java Development Kit).

While it is possible to write bytecode directly, it is much more difficult than writing code in a high-level language, like Java. Therefore, bytecode files, such as Java.CLASS files, certainly generated from source code using a compiler, like a javac.

3. JVM

JVM is a Java Virtual Machine, That is to say, it takes some space from RAM(Random access memory) as a result it created its own machine which is referred to as a virtual machine. It acts as an interpreter (which performs translation of code from one language to another.

After loading byte code into memory, it then verifies the byte code and then converts byte code into actual machine code with the help of the JIT (Just in Time) compiler.

JVM generally uses JIT when the complexity of code is high.

Command to execute Java Program :

java ClassName

Thanks for reading this article so far. If you like this article, then please share it with your friends and colleagues. If you have any questions or feedback, then please drop a note.

Please check most asked programming questions of strings with examples by clicking here, after that youmight get a deep knowledge about string operations

For understanding data structures in an easy way you can check this article on our website.

You can also follow us on Twitter for daily updates.

Leave a Reply

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