• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

Java

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am new to Java and learning from scratch.
I am getting confused between JDK, JRE, and JVM.

Can someone explain the difference in simple terms with a real-life example?
Also, which one is required to run and write Java programs?

Thanks!
 
Marshal
Posts: 82459
594
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yuo need to know what the letters mean:-
  • Java® Development Kit
  • Java® Runtime Environment (no longer available separately)
  • Java® Virtual Machine
  • You need the JDK to produce code. You can't get a JRE on its own. The JVM is a program which emulates a computer running, and it executes the code after you have compiled it.
     
    Bartender
    Posts: 29139
    215
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Campbell Ritchie wrote:You need the JDK to produce code. You can't get a JRE on its own. The JVM is a program which emulates a computer running, and it executes the code after you have compiled it.



    To be precise, the JVM is the program named "java", which is one of the binary executables found in an installed JRE. And, while JREs no longer exist separately, every JDK has had a JRE embedded within it.

    To further note the difference between a JRE and a JDK, the "java" (JVM) program is part of the JRE, but the "javac" (Java compiler) program was only part of the JDK.
     
    Greenhorn
    Posts: 3
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    1. JVM (Java Virtual Machine) → Movie Player
    This is the engine that runs Java programs.
    Just like a movie player plays a movie, JVM executes Java code.
    It converts Java bytecode into machine language the computer understands.
    👉 Purpose: Run Java programs.
    📦 2. JRE (Java Runtime Environment) → Movie Player + supporting files
    JRE includes JVM + required libraries.
    A movie player alone may not be enough — you also need audio/video support.
    Similarly, JRE provides everything needed to run Java programs smoothly.
    👉 Purpose: Complete environment to run Java programs.
    🛠️ 3. JDK (Java Development Kit) → Movie production studio
    JDK includes JRE + development tools (compiler, debugger, etc.).
    Watching a movie needs a player… but creating a movie needs a studio.
    JDK lets you write, compile, and run Java programs.
    👉 Purpose: Develop (create) Java programs.
    ✅ What do you actually need?
    ✔ To run Java programs → JRE is enough
    ✔ To write and run Java programs → JDK is required
    👉 Developers usually install JDK, because it already includes JRE and JVM.
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic