Tutorial

Difference between JDK, JRE, and JVM

Published on August 3, 2022
Default avatar

By Pankaj

Difference between JDK, JRE, and JVM

While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.

The difference between JDK, JRE, and JVM is one of the popular interview questions. You might also be asked to explain JDK vs JRE vs JVM.

Difference between JDK, JRE, and JVM

JDK, JRE, and JVM are core concepts of Java programming language. We don’t use these concepts in programming. But, as a Java developer, we should know about them.

1. JDK

Java Development Kit aka JDK is the core component of Java Environment and provides all the tools, executables, and binaries required to compile, debug, and execute a Java Program. JDK is a platform-specific software and that’s why we have separate installers for Windows, Mac, and Unix systems. We can say that JDK is the superset of JRE since it contains JRE with Java compiler, debugger, and core classes.

2. JVM

JVM is the heart of Java programming language. When we execute a Java program, JVM is responsible for converting the byte code to the machine-specific code. JVM is also platform-dependent and provides core java functions such as memory management, garbage collection, security, etc. JVM is customizable and we can use java options to customize it. For example, allocating minimum and maximum memory to JVM. JVM is called virtual because it provides an interface that does not depend on the underlying operating system and machine hardware. This independence from hardware and the operating system makes java program write-once-run-anywhere.

3. JRE

JRE is the implementation of JVM. It provides a platform to execute java programs. JRE consists of JVM, Java binaries, and other classes to execute any program successfully. JRE doesn’t contain any development tools such as Java compiler, debugger, JShell, etc. If you just want to execute a java program, you can install only JRE. You don’t need JDK because there is no development or compilation of java source code is required. Now that we have a basic understanding of JDK, JVM, and JRE, let’s look into the difference between them.

JDK vs JRE vs JVM

Let’s look at some of the important differences between JDK, JRE, and JVM.

  1. JDK is for development purpose whereas JRE is for running the java programs.
  2. JDK and JRE both contains JVM so that we can run our java program.
  3. JVM is the heart of java programming language and provides platform independence.

Just-in-time Compiler (JIT)

Sometimes you will find JIT alongside JVM, JDK, and JRE in textbooks. JIT is part of the JVM that optimizes the process of converting byte code to machine-specific language. It compiles similar byte codes at the same time and reduces the overall time taken for the compilation of byte code to machine-specific language.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about us


About the authors
Default avatar
Pankaj

author

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
JournalDev
DigitalOcean Employee
DigitalOcean Employee badge
May 17, 2019

Below text from this article - JVM is called virtual because it provides an interface that does not depend on the underlying operating system and machine hardware. This independence from hardware and the operating system is what makes java program write-once-run-anywhere. Does JVM provided interface not depend on underlying platform. If that interface (i.e. loding, linking, JIT, interpreter etc) is same for all platforms then why JVMs are different for each platform. I feel this interface which takes byte code as input and gives you end result is platform dependent which makes Java platform independent. May be you can correct my understanding.

- Love Gupta

    JournalDev
    DigitalOcean Employee
    DigitalOcean Employee badge
    March 15, 2018

    Thanks a lot!

    - Saangram

      JournalDev
      DigitalOcean Employee
      DigitalOcean Employee badge
      February 20, 2018

      Please update the version of Java.

      - srinivas narla

        JournalDev
        DigitalOcean Employee
        DigitalOcean Employee badge
        January 22, 2018

        very well explained,

        - Vitthal Kasbe

          JournalDev
          DigitalOcean Employee
          DigitalOcean Employee badge
          February 7, 2017

          JVM is also platform dependent under JVM , i hope this is a TYPO.

          - Sailendra

            JournalDev
            DigitalOcean Employee
            DigitalOcean Employee badge
            May 18, 2016

            I wish to know step by step execution and impacts , functionalties for jdk, jvm (including memory areas )m jre ? I mean i wish to know end-to-end flow when a java program gets executed (specially through various section inside JVM - among those i also wish to know impacts on memory areas (heap,stack, native area ), class loaders e.t.c.

            - Bibhu Prasad Tripathy

              JournalDev
              DigitalOcean Employee
              DigitalOcean Employee badge
              December 17, 2015

              very good.

              - Leandro

                JournalDev
                DigitalOcean Employee
                DigitalOcean Employee badge
                December 17, 2015

                Hi Pankaj, Thanks for such useful tutorials. You are doing great. Keep it up. I have some doubt about JIT. You said that it optimizes byte code to machine specific language compilation by compiling similar byte codes at same time. My question is that while converting byte code into machine specific code do all the byte code passes through JIT. Because i have heared that only interpretor also have its role in converting byte code into machine specific code. Or only similar byte codes are passes through JIT and rest all passes through interpreter. It would be very useful if you can elaborate it with some example.

                - debu

                  JournalDev
                  DigitalOcean Employee
                  DigitalOcean Employee badge
                  October 18, 2015

                  This is to just let you know that you could update regarding ‘Current JDK Version’ information.

                  - gansai

                    JournalDev
                    DigitalOcean Employee
                    DigitalOcean Employee badge
                    September 25, 2014

                    I’m confused when I go to Oracles site to download the JDK and they ask if you want JDK for Java EE or JDK for Java SE. What if I want to ability to develop both. Do I really have to install 2 separate JDKs?

                    - Mike

                      Try DigitalOcean for free

                      Click below to sign up and get $200 of credit to try our products over 60 days!

                      Sign up

                      Join the Tech Talk
                      Success! Thank you! Please check your email for further details.

                      Please complete your information!

                      Get our biweekly newsletter

                      Sign up for Infrastructure as a Newsletter.

                      Hollie's Hub for Good

                      Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

                      Become a contributor

                      Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

                      Welcome to the developer cloud

                      DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

                      Learn more
                      DigitalOcean Cloud Control Panel