Let's say I need a customized car and have a list of features I want in it. A car must have an engine, steering wheel, brakes, wheels, etc. Theoretically, I define what a car should include to meet my expectations. But is it tangible? Does it exist yet? The simple answer is no.

Now, three companies—Ford, BMW, and Audi—show interest in building my car. Each of these manufacturers creates its own version of the car. While they all meet the basic requirements, they use their own technologies and design philosophies to build it. Additionally, each of these car makers adds extra luxurious features to enhance the car.

Similarly, we know that a Java program written in plain English-like syntax is compiled using javac to generate bytecode. The JVM (Java Virtual Machine) is the engine that understands this bytecode and converts it into machine-understandable language.

However, the JVM itself is not a physical machine. It is a virtual machine, which follows a set of specifications defining how to create an engine that converts bytecode into machine language. To achieve this, the JVM consists of essential components like the Class Loader Subsystem, Memory Areas, and Execution Engine.

The JRE (Java Runtime Environment) is an implementation of the JVM. Many companies, such as Oracle and Amazon, have developed their own JVM implementations. A JVM implementation, along with necessary libraries, is called the JRE. Popular JVM implementations include HotSpot JVM (developed by Oracle and OpenJDK), OpenJ9 (by the Eclipse Foundation), and Amazon Corretto (by Amazon).

Just as car manufacturers need toolkits to build cars, Java developers need various tools to develop, test, and run Java programs. To compile a Java program, we use javac; to load a Java program, we use java; to run it, we need the JRE; to understand Java APIs, we usejavadoc, etc. All these tools combined into a single package are called the JDK (Java Development Kit).

As a Java software developer, you need the JDK to develop, test, and run Java applications. However, if you only need to run an already-developed Java application, you just need the JRE.

Key Differences Among JVM, JRE, and JDK

JVM (Java Virtual Machine) The JVM is the core component responsible for executing Java bytecode. It acts as an abstraction layer between the compiled Java code and the underlying operating system, ensuring platform independence. It includes key components like the Class Loader, Just-In-Time (JIT) Compiler, and Garbage Collector (GC) but does not provide development tools or libraries.

JRE (Java Runtime Environment) The JRE includes the JVM and essential libraries required to run Java applications. It provides core class libraries like java.lang, java.util, and java.io that Java programs need to function. It is meant for end-users who need to run Java applications but do not require development tools.

JDK (Java Development Kit) The JDK is a superset of the JRE and contains everything required to develop, compile, and run Java programs. It includes the JRE, Java compiler (javac), debugging tools, and other utilities like jar (for packaging applications) and javadoc (for generating documentation). Without the JDK, writing and compiling Java code is not possible, making it essential for Java developers.

In summary, the JVM executes Java applications, the JRE provides the environment to run them, and the JDK offers the complete toolset for Java development. Choosing the right component depends on whether you are running Java applications or developing them.

  1. 🚀

Chinmay Biswal
Solution Architect