Understanding the Java Architecture is essential for grasping how Java programs are compiled, executed, and made platform-independent. It consists of several components that work together to run your Java application.
๐งฑ Core Components of Java Architecture
Component | Description |
---|---|
๐ Source Code | You write your Java code in .java files using a text editor or IDE |
๐งฎ Compiler (javac) | Converts .java source code into .class bytecode |
๐ฆ Bytecode | Intermediate, platform-independent code understood by the JVM |
๐ง Java Virtual Machine (JVM) | Executes the bytecode and makes Java platform-independent |
⚙️ Java Runtime Environment (JRE) | Provides the JVM + core libraries to run Java programs |
๐ง Java Development Kit (JDK) | Contains the JRE + development tools (compiler, debugger, etc.) |
๐ Java Program Execution Flow
-
Write your Java program:
Hello.java
-
Compile it using
javac Hello.java
→ generatesHello.class
-
Run it with
java Hello
→ JVM loads and executes bytecode
๐ Step-by-Step Flow Diagram (Textual)
☕ Java Virtual Machine (JVM)
-
JVM is the engine that runs Java bytecode on your system.
-
It performs:
-
Class loading
-
Bytecode verification
-
Memory management (Garbage Collection)
-
Just-In-Time (JIT) compilation
-
✅ JVM ensures your Java code runs anywhere with a compatible JVM—making it truly portable.
๐ฆ Java Runtime Environment (JRE)
-
A package that includes:
-
JVM
-
Java class libraries
-
Other files required to run Java applications
-
You need JRE to run Java apps, but not to develop them.
๐ ️ Java Development Kit (JDK)
-
A complete software development package containing:
-
JRE
-
Compiler (javac)
-
Debugger (jdb)
-
Other dev tools
-
You need JDK to write, compile, and debug Java programs.
๐ง Summary Table
Component | Role |
---|---|
.java File | Human-readable source code |
javac | Compiles code into bytecode |
.class File | Platform-independent bytecode |
JVM | Runs the bytecode |
JRE | JVM + libraries to run code |
JDK | JRE + tools to write and compile code |