This article is about Introduction to JDK, JRE, and JVM, which describes JDK, JRE, and JVM and the differences between them.
Table of Contents
Java Development Kit
Java Development Kit (JDK) is a software that provides the development environment to develop Java applications. It provides the tools and technology needed to develop, test, and run Java applications. It also contains tools like Java compilers and debuggers.
Java Runtime Environment
Java Runtime Environment (JRE), also called Java RTE, is a subset of JDK. It contains the necessary libraries and files which describe the minimum requirements to run a Java application. Java Virtual Machine is a subset of Java Runtime Environment.
Java Virtual Machine
Java Virtual Machine (JVM) is an abstract machine and doesn’t exist as a real machine. It is software that reads the Java Bytecode and executes the file. It is responsible for Java code execution on a specific operating system and hardware architecture. JVM is a part of Java Runtime Environment (JRE).
So, in short, JRE is a part of JDK, and JVM runs on both JDK and JRE.
The difference between Compiler and Interpreter
Reads the whole program’s code simultaneously.
It reads the whole program’s code line by line.
It takes less time to read code.
It takes more time to read code.
Intermediate Object Code is Generated
No Intermediate Object Code is Generated
It takes more memory
It takes less memory
Errors are displayed after the entire program is checked
Errors are displayed at the time of checking
Example: C Compiler
When Java compiles the Java program using the javac tool, the Java compiler converts the source code into byte code.
What is Java Byte Code?
Java Byte Code is a .class extension file that Java Compilation releases after reading the Java source file.
What happens at runtime?
At runtime, the following steps are performed:
Classloader: The subsystem of JVM is used to load class files.
Bytecode Verifier: Checks the code fragments for illegal code that can violate access rights to objects.
Interpreter: Read bytecode stream, then execute the instructions.
Difference between JDK, JRE, and JVM
JVM (Java Virtual Machine) is an abstract machine. It is called a virtual machine because it doesn’t physically exist. It is a specification that provides a runtime environment in which Java bytecode can be executed. It can also run programs written in other languages and compiled to Java bytecode.
JVMs are available for many hardware and software platforms. JVM, JRE, and JDK are platform dependent because the configuration of each OS is different from the other. However, Java is platform-independent.
The JVM performs the following main tasks:
- Loads code,
- Verifies code,
- Executes code
- Provides runtime environment
JVM provides definitions for the:
- Memory area,
- Class file format,
- Register set,
- Garbage-collected heap,
- Fatal error reporting, etc.
JRE is an acronym for Java Runtime Environment. It is also written as Java RTE. The Java Runtime Environment is a set of software tools used to develop Java applications. It is used to provide the runtime environment. It is the implementation of JVM. It physically exists. It contains a set of libraries + other files that JVM uses at runtime.
JDK is an acronym for Java Development Kit. The Java Development Kit (JDK) is a software development environment for developing Java applications and applets. It physically exists. It contains JRE + development tools.
JDK is an implementation of any of the Java Platforms below released by Oracle Corporation:
- Standard Edition, Java Platform
- Enterprise Edition, Java Platform
- Micro Edition Java Platform.
The JDK contains a private Java Virtual Machine (JVM) and a few other resources, such as an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc), etc., to complete the development of a Java Application.
Please comment below if you need help with something in the above-discussed topic and have further questions.