JVM, JRE and JDK - Which one do I need for Mule?



I’m not a developer, but I always wanted to be. The first time I approached Java I got very confused with the jargon. JVM, JRE, JDK... what do I really need?
In this post, we will see what all those terms mean so that, the next time we need to install Java we know exactly what we need to do.

JVM

It stands for Java Virtual Machine. And that’s exactly what it is, a Virtual Machine that runs Java bytecode. This creates that level of abstraction that enables our computer to run Java programs, regardless of the platform that executes the code.

The Java bytecode is the code produced after the source code is compiled. The JVM runs this code at the operating system level.

The JVM handles the resources - the memory, the garbage collection, the CPU, all the system calls...
There is a version of the JVM for each platform, that is, there are different JVMs for Windows, macOS, Linux but the java code is always the same. That’s what makes Java so popular.

The JVM is part of both, the JRE and the JDK

JRE

It stands for Java Runtime Environment. The JRE provides the environment in which the Java programs run, it contains everything that is necessary to run Java applications. 
For that, the JRE contains:
  • The Java Virtual Machine - The core component that executes the Java bytecode
  • All the core Java libraries - the set of Java class libraries and other resources that the JVM needs to run Java applications.
We could say that 
JRE = JVM + libraries + runtime

The JRE is the minimum software required in a system to run Java applications. This means:

  • Java applications can run without the JDK but not without the JRE. 
  • JVM is required but cannot run Java apps alone, it needs the JRE.

JDK

The JDK is the Java Development Kit. It’s a full development kit to DEVELOP (not run) Java applications. The JDK includes the JRE plus a set of development tools for compiling, debugging and running Java apps
    JDK = JRE + development tools

The
 JDK is meant for Developers. 

Java applications can run with the JDK but the JDK contains more than it’s needed. To only run Java apps it’s enough the JRE.

OracleJDK

When people say "JDK," they often mean the Oracle JDK, which is Oracle's commercial version of the JDK. It includes performance improvements and additional tools not found in OpenJDK.

The Oracle JDK used to be free for all uses, but as of Java 11, it is available under a commercial license, which means you need to pay for support and updates unless you're using it for personal or development purposes.

OpenJDK

OpenJDK is an open-source version of the JDK. It includes the same tools and libraries as the OracleJDK, but without some of the proprietary tools and performance optimizations found in the Oracle version. However, it is freely available and can be modified and redistributed by anyone. OpenJDK is a popular choice for developers who want a free and open-source alternative to the JDK.

OpenJDK is maintained by a community that includes contributions from Oracle, as well as other companies like Red Hat, IBM, and Amazon.
OpenJDK is licensed under the GNU General Public License (GPL), which allows free usage and distribution, even in commercial environments.
In terms of versions, OpenJDK provides the same major releases as Oracle JDK but doesn't always include the same extended support unless distributed by third parties.


AdoptOpenJDK

AdoptOpenJDK is a community-driven initiative to provide prebuilt OpenJDK binaries that are free to use in production environments. It has since moved under the Eclipse Foundation and is now called Eclipse Temurin.


Like OpenJDK, AdoptOpenJDK is free and open-source, but with additional emphasis on providing certified, production-ready builds. It also provides LTS (Long-Term Support) for certain Java versions.

Many users prefer AdoptOpenJDK/Eclipse Temurin because it is free to use, has community and vendor support, and is trusted for production environments. It provides consistent updates, security patches, and LTS versions that companies can rely on.


Which one do I need for the Mule? JRE or JDK?

This is a very interesting question and the answer is... it depends.
If we are developing Mule apps, with Anypoint Studio then we definitely need the JDK
If, on the other hand, we are only using the Mule runtime, for example using the Standalone deployment type with a server running the mule runtime, that’s a different story.
Based on the explanation above, you might think that, considering Mule is based on Java, we could just use the JRE to run mule apps. Technically yes, but the reality is that Mulesoft specifies as a requirement for a Mule standalone server to install the full JDK. That’s because with the JDK we will be able to, not only start the Mule runtime and deploy applications but also to use troubleshooting CLI and GUI tools. For example, with the JDK we will be able to get thread dumps, run the garbage collection or monitor with JConsole.


And which JDK? OracleJDK, OpenJDK or AdoptOpenJDK?

Now the question is - which JDK? OracleJDK, OpenJDK or AdoptOpenJDK?
Mulesoft chose to join the AdoptOpenJDK initiative a few years ago. The AdoptOpenJDK is the JVM that is currently used for the Mule Runtime in Cloudhub or Runtime Fabric. However, it is not required that you must only use AdoptOpenJDK, you could use OpenJDK for your standalone runtimes. Actually, Mule runtime is supported to run under JDK 8 and 11.

Previous Post Next Post