Author: SAI K
In this chapter, we will discuss an important definition of JVM, JRE, and JDK in the Java programming language and the difference between them.
Java technology is both a programming language and a platform. The Java programming language is a high-level object-oriented language with a particular syntax and style. A Java platform is a particular environment in which Java programming language applications run.
The JDK is the cornerstone for any Java developer, providing the essential tools needed to develop Java
applications and applets. It includes the JRE for running the Java applications you've developed, along with
an assortment of development tools such as a compiler (javac
), an archiver (jar
),
and a documentation generator (Javadoc
), among others. The JDK allows developers to write Java
programs and convert them into a format that can be executed by the JRE and JVM.
javac
): Transforms your Java code into bytecode.The diagram below shows that the JDK (Java Development Kit) is a software development kit that contains everything in the JRE, plus tools such as the compiler, debugger, JavaDoc, keytool, etc., necessary for developing and running Java programs or applications.
The JRE is what you need to run Java applications. It's a part of the JDK but can also be distributed separately to run Java applications. The JRE consists of the JVM, core libraries, and other components to run applications written in Java. However, it doesn't include development tools like compilers or debuggers.
The JVM is an abstract computing machine that enables a computer to run a Java program. When you run a Java application, the JVM reads the compiled bytecode (generated by the JDK) and interprets it into machine code for execution. The JVM ensures Java applications can run on any device or operating system that has a compatible JVM, embodying Java's write-once, run-anywhere principle.
Primary Purpose: It serves as a comprehensive suite for developing Java applications and applets equipped with compilers, tools, and libraries.
javac
), tools for debugging and monitoring.Use Case: Essential for developers writing Java code, as it provides all necessary tools for code compilation, documentation, and packaging.
Enhanced Capability: Offers tools like javadoc
for generating documentation and
jarsigner
for signing Java Archive (JAR) files, facilitating professional Java application
development.
Primary Purpose: Provides the environment to run Java applications and applets on a device, encompassing necessary libraries and the JVM.
Use Case: Needed to run Java applications. It's essentially a package that allows a computer system to run Java programs.
Simplified Execution: Enables users to run Java applications efficiently and safely without the tools for application creation or debugging.
Heart of Java: Acts as the execution engine that runs Java bytecode, making Java applications platform-independent.
This feature enables Java’s "write once, run anywhere" (WORA) capability by allowing Java bytecode to be executed on any device equipped with a compatible JVM.
In the next chapter, we will learn about Variables in Java - Local Variable, Class Variable, and Instance Variable.