JVM versus JRE versus JDK: What’s the difference?
30 June 2021

5 min read

Author
IBM Cloud Education IBM Cloud Education
How do JVM, JRE and JDK relate and work together in the Java development process?

Java is one of the most popular programming languages that are used in developing environments today. It is primarily used for back-end development projects, game development, and desktop and mobile computing. Read on and find out how Java virtual machine (JVM), Java Runtime Environment (JRE), and Java Development Kit (JDK) each play a role in the Java development process. You'll also learn about their relationship to each other and the differences that set them apart.

What is Java virtual machine (JVM)?

Java virtual machine, or JVM, loads, verifies, and runs Java bytecode. It is known as the interpreter or the core of the Java programming language because it runs Java programming.

The role of JVM in Java

JVM is responsible for converting bytecode to machine-specific code and is necessary in both JDK and JRE. It is also platform-dependent and performs many functions, including memory management and security. In addition, JVM can run programs that are written in other programming languages that have been converted to Java bytecode.

Java Native Interface (JNI) is often referred to in connection with JVM. JNI is a programming framework that enables Java code running in JVM to communicate with (that is, to call and be called by) applications that are associated with a piece of hardware and specific operating system platform. These applications are called native applications and can often be written in other languages. Native methods are used to move native code written in other languages into a Java application.

JVM components

JVM consists of three main components or subsystems:

  • Class Loader Subsystem is responsible for loading, linking, and initializing a Java class file (that is, “Java file”), otherwise known as dynamic class loading.
  • Runtime Data Areas contain method areas, PC registers, stack areas, and threads.
  • Execution Engine contains an interpreter, compiler, and garbage collection area.
What is Java Runtime Environment (JRE)?

Java Runtime Environment, or JRE, is a set of software tools responsible for execution of the Java program or application on your system.

JRE uses heap space for dynamic memory allocation for Java objects. JRE is also used in JDB (Java Debugging).

The role of JRE in Java

If a programmer would like to run a Java program by using the Java command, they should install JRE. If they are only installing (and not developing or compiling code), then only JRE is needed.

JRE components

Besides the Java virtual machine, JRE is composed of various other supporting software tools and features to get the most out of your Java applications.

  • Deployment solutions: Included as part of the JRE installation are deployment technologies like Java Web Start and Java plug-in that simplify the activation of applications and provide advanced support for future Java updates.
  • Development toolkits: JRE also contains development tools that are designed to help developers improve their user interface. Some of these toolkits include the following:
    • Java 2D: An application programming interface (API) used for drawing two-dimensional graphics in Java language. Developers can create rich user interfaces, special effects, games, and animations.
    • Abstract Window Toolkit (AWT): A graphical user interface (GUI) that is used to create objects, buttons, scroll bars, and windows.
    • Swing: Another lightweight GUI that uses a rich set of widgets to offer flexible, user-friendly customizations.
  • Integration libraries: Java Runtime Environment provides several integration libraries and class libraries to assist developers in creating seamless data connections between their applications and services. Some of these libraries include the following:
    • Java IDL: Uses Common Object Request Brokerage Architecture (CORBA) to support distributed objects written in the Java programming language.
    • Java Database Connectivity (JDBC) API: Provides tools for developers to write applications with access to remote relationship databases, flat files, and spreadsheets.
    • Java Naming and Directory Interface (JNDI): A programming interface and directory service that lets clients create portable applications that can fetch information from databases by using naming conventions.
  • Language and utility libraries: Included with JRE are Java.lang. and Java.util. packages that are fundamental for the design of Java applications, package versioning, management, and monitoring. Some of these packages include the following
    • Collections framework: A unified architecture that is made up of a collection of interfaces that are designed to improve the storage and process of application data.
    • Concurrency utilities: A powerful framework package with high-performance threading utilities.
    • Preferences API: A lightweight, cross-platform persistent API that enables multiple users on the same machine to define their own group of application preferences.
    • Logging: Produces log reports—such as security failures, configuration errors, and performance issues—for further analysis.
    • Java Archive (JAR): A platform-independent file format that enables multiple files to be bundled in JAR file format, significantly improving download speed and reducing file size.
What is Java Development Kit (JDK)?

Java Development Kit, or JDK, is a software development kit that is a superset of JRE. It is the foundational component that enables Java application and Java applet development. It is platform-specific, so separate installers are needed for each operating system (for example, Mac, Unix, and Windows).

The role of JDK in Java

JDK contains all the tools that are required to compile, debug, and run a program developed using the Java platform. (It’s worth noting that Java programs can also be run by using command line.)

JDK components

JDK includes all the Java tools, executables, and binaries that are needed to run Java programs. This includes JRE, a compiler, a debugger, an archiver, and other tools that are used in Java development.

Java SE versus Java EE

Java is synonymous with Java Standard Edition (Java SE) or Core Java. All three euphemisms refer to the basic Java specification that includes the act of defining types and objects. Java EE, on the other hand, provides APIs and is typically used to run larger applications. The content of this blog focuses on Java SE.

How JVM, JRE and JDK work together

Let’s first look at how the three core components of Java work together, and then we can examine the differences. The following diagram provides an image of how JVM, JRE, and JDK fit together in the Java landscape.

If you envision a baseball sliced open, it contains three main components: the round cushioned core, the wool and cotton midsection and the cowhide exterior. A ball without all three of these layers will not perform its intended function. Much like the three basic parts of a baseball, JVM, JRE, and JDK all have specific functions. Without all three, Java will not operate successfully.

In the following video, Jamil Spain further explains how JRE and JDK relate:

JDK versus JRE versus JVM: Key differences

And now, for the differences:

  • JDK is the development platform, while JRE is for execution.
  • JVM is the foundation, or the heart of the Java programming language, and ensures the program’s Java source code will be platform-agnostic.
  • JVM is included in both JDK and JRE—Java programs won’t run without it.
Complementary technologies

There are many complementary technologies that can be used to enhance JVM, JRE, or JDK. The following technologies are among the most frequently used:

  • Just-in-time Compiler (JIT) is part of JVM and optimizes the conversion of bytecode to machine code. It selects similar bytecodes to compile at the same time, reducing the overall duration of bytecode to machine code compilation.
  • Javac, another complementary tool, is a compiler that reads Java definitions and converts them into bytecode that can run on JVM.
  • Javadoc converts API documentation from Java source code to HTML. This is useful when creating standard documentation in HTML.
JVM and container technology

Java virtual machine (JVM) is used to create—you guessed it—virtual machines (VMs). VMs are servers that allow multiple applications to run on the same underlying physical hardware without impacting one another. This provides better use of resources and makes it much easier and cost-effective to scale than traditional infrastructure. VMs are also easily disposable because of their independence. When you no longer need the application, you simply take down the VM.

Containers take this abstraction to the next level and virtualize the OS kernel. The absence of the OS renders containers even more lightweight, fast, and flexible than VMs.

Java, JVM, JDK, JDK, and IBM®

For many organizations, Java remains a vital part of application development and provides a solid foundation when creating portable and scalable solutions. It can also serve a key role in modernizing applications on the journey to cloud.  

Take the next step by explore OpenJDK and IBM Runtimes for Business, which provides reliable and cost-effective commercial support for implementing, monitoring, and managing Java applications.

Elevate your cloud game

In 5 minutes get info, insights and news on the next era of hybrid multicloud solutions to level up your cloud game.

Get started with an IBM Cloud account today

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.

Subscribe now More newsletters