JDK provides programmers with a set of tools (like javac, debugger, javap, appletviewer etc..) for developing Java programs. JDK includes JRE.
JRE provides the run-time engine JVM along with the class libraries which contains the predefined functionality.
Using JDK programmers can create and run Java programs. But with JRE alone, programmers or users can only run already compiled Java programs. We cannot create Java programs using only JRE.
Java Virtual Machine (JVM) is an abstract computing machine that allows a computer to run programs written in Java. There are three concepts related to JVM:
The JVM specification is a document which contains formal information about what a JVM implementation should contain. A single specification allows various interoperable implementations.
A JVM implementation is a computer program that meets the requirements given in JVM specification.
An instance of a JVM is an implementation running in a process that executes bytecode. Oracle’s implementation of JVM specification is known as HotSpot. Other famous implementations are JRockit, Kaffe, IBM J9.
Overview of the architecture of JVM is as shown below:
A class loader implementation is a program that should be able to perform the following activities:
- Loading: finds and imports the binary data for a type
- Linking: performs verification, preparation, and resolution (optional)
- Initialization: Invokes Java code that initializes class variables to their proper initial values
The heap area of JVM is used for dynamic memory allocation. In HotSpot the heap is divided into generations:
- The young generation stores objects whose lifetime is short.
- The old generation stores objects which persist for longer durations.
The permanent generation area stores class definitions and other metadata. This area is removed in Java 8.
Take your time to comment on this article.