✅ Java Virtual Machine (JVM)

 


JVM (Java Virtual Machine) is an abstract computing machine that enables a computer to run Java programs and programs written in other languages compiled to Java bytecode. It is a key component of the Java Runtime Environment (JRE).


Key Features of JVM:

1. Platform Independence – Java code is compiled into bytecode, which can run on any system with a compatible JVM.

2. Automatic Memory Management (Garbage Collection) – JVM manages memory and automatically reclaims unused objects.

3. Security – It includes a class loader and bytecode verifier to prevent unauthorized access.

4. Just-In-Time (JIT) Compilation – JVM translates bytecode into native machine code for better performance.

5. Multithreading Support – It enables concurrent execution of multiple threads.



JVM Architecture:

1. Class Loader – Loads class files and manages dynamic linking.


2. Runtime Memory Areas:

- Method Area – Stores class-level structures like metadata and static variables.

- Heap – Stores objects and instance variables.

- Stack – Contains method-specific data, including local variables.

- PC Register – Holds the address of the current executing instruction.

- Native Method Stack – Manages native method calls.

3. Execution Engine:

- Interpreter – Executes bytecode line by line.

- JIT Compiler – Converts bytecode into native code for better performance.

4. Garbage Collector – Frees unused memory automatically.

5. Native Interface – Connects JVM with native libraries and OS functions.


JVM vs JRE vs JDK:

JVM – Runs Java bytecode.

JRE (Java Runtime Environment) – Includes JVM + libraries to run Java applications.

JDK (Java Development Kit) – Includes JRE + development tools (compiler, debugger).




.


ليست هناك تعليقات:

إرسال تعليق