Difference between JVM and HotSpot?

The definition of what exactly is a Java Virtual Machine is stated in the Java Virtual Machine Specification

The JVM is by definition a virtual machine, i.e. a software machine that simulates what a real machine does. Like a real machine, it has an instruction set, a virtual computer architecture and an execution model. It is capable of running code written with this virtual instruction set, pretty much like a real machine can run machine code.

HotSpot is an implementation of the JVM concept. It was originally developed by Sun, and now it is owned by Oracle. There are other implementations of the JVM specification, like JRockit, IBM J9, among many others.

See List of Java Virtual Machine Implementations

The OpenJDK is a project under which an open source implementation of HotSpot (and many other pieces of the JDK e.g. compiler, APIs, tools, etc) is developed.


Note: AdoptOpenJDK has changed its name to Adoptium after moving to the Eclipse Foundation in late 2020-06.


Difference between JVM and HotSpot?

A Java Virtual Machine (JVM) is an imaginary computer that has never been physically built as hardware. A JVM runs programs compiled to its imaginary instruction set written to storage as an intermediate representation known as bytecode.

At runtime, the bytecode must be translated from the imaginary instruction set to the actual instruction set of the CPU of the host machine. This can be done on-the-fly by an interpreter. Or the bytecode can be fully compiled and cached, to run faster than through the interpreter, in a process known as Just-In-Time (JIT) compiling.

Over the decades, there have been many implementations of the JVM. Most have fallen away.

HotSpot is one implementation of JIT technology that starts by running interpreted, and watches the actual performance of the app. Parts of the app are then selected to be fully-compiled as native code and cached, for much faster execution. HotSpot was developed at Sun as a commercial product. After acquiring Sun, Oracle further evolved HotSpot by combining important parts of their competing product, JRockit. HotSpot is now open-sourced through the OpenJDK project, available free-of-charge.

Another such implementation in OpenJ9, developed by IBM, and now open-sourced through the Eclipse Foundation and available free-of-charge. Some JVM distributions built on OpenJDK replace HotSpot with OpenJ9 while still using the rest of OpenJDK such as the Java SE class libraries. For example, the pre-built distributions available at AdoptOpenJDK provide your choice of HotSpot or OpenJ9 on some hardware.

Diagram showing history of HotSpot & JRockit merging, and OpenJ9 both available in AdoptOpenJDK.

Diagram showing history of HotSpot & JRockit merging, and OpenJ9 both available in AdoptOpenJDK

What exactly is HotSpot and how does it relate to JVM and OpenJDK? Is it a library? What exactly does it do?

  • HotSpot is an implementation of the part of a JVM that interprets and/or compiles Java bytecode to be executed on the host CPU.
  • OpenJ9 is an alternative.

OpenJ9 is generally known for much faster starting and much lower memory usage initially, while HotSpot may run more efficiently overall for long-running apps. Both are well-regarded, well-worn, and available with distributions of OpenJDK.

OpenJDK is an open-source project that fully implements the Java Specifications, JSRs, and JEPs that define the Java platform. Every JVM implementation I know of today is based entirely or mostly on the OpenJDK codebase and uses either HotSpot or OpenJ9 technology.

Besides the JVM, OpenJDK also provides an implementation in source code for all classes required by the Java SE specifications, such as java.lang, java.util, java.time, and other packages.

Also, what is the difference between OpenJDK and HotSpot?

The source code for HotSpot is housed, maintained, and further developed as part of the OpenJDK project. The alternative, OpenJ9, is housed, maintained, and further developed at the Eclipse Foundation, while replacing HotSpot in some distributions of OpenJDK.

Some distributions of Java technology choose to ship with HotSpot. Some distributions choose to substitute the portion of the OpenJDK codebase that is HotSpot with the alternative, OpenJ9.

Here is a flow chart graphic to help you choose a vendor for a distribution of the Java platform.

Flowchart guiding you in choosing a vendor for a Java 11 implementation

Motivations in choosing a vendor for Java