Difference between JRE JVM and JDK

JRE JVM and JDK are the terms used in Java Programming Language. In this Article We will see what are the differences between JRE (Java Runtime Environment), JVM (Java Virtual Machine) and JDK (Java Development Kit)?

JRE (Java Runtime Environment)
Java Runtime Environment contains JVM, class libraries, and other supporting files. It does not contain any development tools such as compiler, debugger, etc. JVM runs the program and it uses the class libraries, and other supporting files provided in JRE. If you want to run any java program, you need to have JRE installed in the system.

JVM (Java Virtual Machine)
The Java Virtual Machine provides a platform independent way of executing code. Programmers can concentrate on writing software, without having to be concerned with how or where it will run, when we compile a Java file, output is a .class file, the class file consists of Java byte codes which are understandable by JVM. Java Virtual Machine interprets the byte code into the machine code depending upon the underlying operating system and hardware combination.

Note that JVM itself not a platform independent. It only helps Java to be executed on the platform-independent way. When JVM has to interpret the byte codes to machine language, then it has to use some native or operating system specific language to interact with the system.

JDK (Java Development Kit)
Java Developer Kit contains tools needed to develop the Java programs and JRE to run the programs. The tools include compiler (javac.exe), Java application launcher (java.exe) etc. Compiler converts java code into byte code. Java application launcher opens a JRE, loads the class and invokes its main method.

You need JDK, if you want to write and compilethe program. For running java programs, JRE is sufficient. JDK is mainly targeted for java development. I.e. you can create a Java file (with the help of Java packages), compile a Java file and run a java file.

In short here are few differences between JRE, JDK and JVM:-
1) JRE only contain environment to execute java program
2) JRE and JDK come as installer while JVM are bundled with them.
3) JVM comes along with both JDK and JRE and created when you execute Java program by giving java command.

Just in Time Compiler (JIT)

A JIT compiler runs after the program has started and compiles the code usually bytecode or some kind of VM instructions on the fly. JIT is the part of Java Virtual machine which optimize byte code to machine instruction conversion part by compiling similar byte codes at same time and thus reducing overall execution time. JIT also performs several other optimizations such as in-lining function.

That’s all on JRE, JDK and Java Virtual machine and difference between them.

Reference:
JVM Specification

Leave a Comment