From Power ON → Firmware → OS Kernel → Process Creation → JVM → Bytecode Execution, every layer matters when you’re designing:

 I’ve created this visual to help junior developers understand the full journey — from hardware to Java execution.



Break down it into 4 clear stages:

Stage 1: System Boot

A computer contains:

CPU → the "thinking" unit

RAM → temporary workspace for running programs

Hard Disk / SSD → permanent storage

When the computer is off:

RAM is empty

CPU has no instructions

OS resides on the disk, not in memory

The computer doesn’t yet know where the OS is.

Step 1 – Power ON: Firmware Starts

Firmware: a small permanent program on the motherboard (examples: BIOS/UEFI)

Why is it needed?

CPU doesn’t know where OS is

CPU doesn’t know how to use RAM or disk

Firmware acts as the CPU’s first teacher

What firmware does:

Takes control of CPU

Performs hardware checks (RAM, CPU, Disk) → POST (Power-On Self Test)

Finds a bootable device → locates the OS


Step 2 – Bootloader Loads

Firmware loads the bootloader from the disk:

Windows → Windows Boot Manager

Linux → GRUB

Bootloader loads the OS kernel into RAM

CPU control is handed to the kernel

Now the Operating System is running and Ready

OS kernel:

Manages CPU scheduling

Controls memory

Loads drivers (Disk, Network, USB)

Provides system calls

Then:

Background services start

GUI / shell runs

User login is allowed

Computer is now ready to use


Stage 2: Java Development

Step 3 – Developer writes code in Java

Saves it as a .java file (plain text, human-readable)

Example:

public class HelloWorld {

    public static void main(String[] args) {

        System.out.println("Hello");

    }

}

CPU cannot execute this directly—it only understands binary (0s & 1s)


Stage 3: JVM Compilation

Step 4 – Compile using javac

Command: 

javac HelloWorld.java

OS receives the command

Searches for javac in the PATH

Loads javac executable from disk

OS creates a new process → Javac process

Javac internally: Reads .java file

Checks syntax & errors

Generates .class file → bytecode

Bytecode is platform-independent and JVM-ready


Stage 4: JVM Execution

Step 5 – Run Java 

Command:

java HelloWorld

OS receives the command

Loads java executable from disk

OS creates a new process → JVM process

The JVM is a software-based virtual machine that runs on top of the operating system and provides an isolated runtime environment for executing Java bytecode.



Step 6 – JVM Runtime Memory

JVM allocates memory areas in RAM:

Area     Purpose

Heap     Objects storage

Stack     Method calls & local variables

Metaspace     Class metadata

Code Cache    JIT compiled code


JVM exists only at runtime; it’s temporary

JVM Internal Components

ClassLoader → loads classes

Bytecode Verifier → ensures safety

Execution Engine → converts bytecode to CPU instructions

Garbage Collector → cleans memory


Application Classes Load

JVM loads .class files from disk

Verifies bytecode

Starts execution → runs main() method


Step 7 – Isolated Execution Environment

Java program cannot access other apps’ memory

Cannot directly manipulate hardware

JVM creates a sandbox

Checks security & permissions

Result: Java programs run safely and securely


Step 8 – JVM as an Abstraction Layer

Java program doesn’t know CPU instructions or OS system calls

JVM converts bytecode into machine-specific instructions

JVM is OS-specific (Windows, Linux, macOS)

Output is consistent across all platforms


This is why Java is “Write Once, Run Anywhere”


JDK vs JRE vs JVM

Terms            Meaning

JDK               Java Development Kit = JRE + Tools (javac, jar, javadoc)

JRE          Java Runtime Environment = JVM + Java libraries

JVM    Java Virtual Machine = Bytecode interpreter & execution engine


Next Topic: Class Loader Subsystem: jvm-classloader



Comments

Popular posts from this blog

JVM-ClassLoader