DEV Community

Vidya
Vidya

Posted on

Java Architecture

JDK
JDK (Java Development Kit) provides tools and libraries to develop Java applications, working with JRE and JVM. JRE (Java Runtime Environment) offers the libraries and JVM needed to run Java programs. JVM (Java Virtual Machine) executes the compiled Java bytecode on the system.

             Java Source Code
             (.java)
                │
                ▼
    ┌────────────────────────┐
    │          JDK           │
    │                        │
    │  Development Tools     │
    │  ┌──────────────────┐ │
    │  │ javac → Compile  │ │
    │  │ java  → Run      │ │
    │  │ javadoc → Docs   │ │
    │  │ jar   → Package  │ │
    │  └─────────┬────────┘ │
    │            │          │
    │            ▼          │
    │        ┌────────┐     │
    │        │  JRE   │     │
    │        │        │     │
    │        │  JVM   │     │
    │        │ + Libs │     │
    │        └────────┘     │
    └────────────────────────┘
                │
                ▼
          OS / Hardware
Enter fullscreen mode Exit fullscreen mode

JRE
The Java Runtime Environment (JRE) is a software package that Java programs require in order to run successfully. The JRE consists of the Java Virtual Machine (JVM), which executes Java bytecode using a combination of interpretation and Just-In-Time (JIT) compilation.The JRE is mainly responsible for running Java applications, while deployment tools are primarily provided in the Java Development Kit (JDK).

                        .class file (Bytecode)
              │
              ▼
    ┌─────────────────────────┐
    │           JRE           │
    │   (Java Runtime Env.)   │
    │                         │
    │  ┌───────────────┐      │
    │  │      JVM      │      │
    │  │───────────────│      │
    │  │ Execution     │      │
    │  │ Engine        │      │
    │  │ ┌─────────┐   │      │
    │  │ │Interpreter│  │      │
    │  │ └─────────┘   │      │
    │  │ ┌─────────┐   │      │
    │  │ │   JIT    │  │      │
    │  │ │ Compiler │  │      │
    │  │ └─────────┘   │      │
    │  └───────────────┘      │
    │  ┌───────────────┐      │
    │  │ Java Libraries│      │
    │  │ (API Classes) │      │
    │  └───────────────┘      │
    └─────────────────────────┘
              │
              ▼
            Output
Enter fullscreen mode Exit fullscreen mode

JVM
A JVM is a virtual machine that provides an execution environment for Java bytecode. JVM acts as an intermediary layer between the Java code and the foundational hardware and operating system, enabling Java programs to run efficiently and reliably across various platforms and systems.

           Bytecode
        (.class)
           │
           ▼
    ┌───────────────────────┐
    │          JVM          │
    │                       │
    │  ┌─────────────────┐ │
    │  │  Class Loader   │ │
    │  └────────┬────────┘ │
    │           │          │
    │           ▼          │
    │  ┌─────────────────┐ │
    │  │ Runtime Data    │ │
    │  │    Areas        │ │
    │  │ (Heap, Stack)  │ │
    │  └────────┬────────┘ │
    │           │          │
    │           ▼          │
    │  ┌─────────────────┐ │
    │  │ Execution       │ │
    │  │   Engine        │ │
    │  │ (Interpreter + │ │
    │  │   JIT + GC)    │ │
    │  └────────┬────────┘ │
    │           │          │
    │           ▼          │
    │        Output        │
    └───────────────────────┘
Enter fullscreen mode Exit fullscreen mode

Top comments (0)