How Java Works ? (JDK,JRE,JVM)
Q . How Java Works ? (JDK,JVM,JRE)
---> (In Short)
1 ) JDK (Java Development Kit ) :
* It Provides "Javac" Compiler Without "JDK" we can't Compiler our Source Code(.java) into Byte Code(.class) file for that we need JDK .
2) JVM (Java Virtual Machine) :
* It Excecutes Our Byte Code(.class) file in that "JVM" Search for PSVM(String args[])
to Run the code:
3) JRE (Java Runtime Enviroment) :
* It Normally provides Libraries and various Components to our "JVM" Like an example
(java.util, java.lang).
### Detailed Explaination :
1. **Development with JDK**:
- Write Java source code (`.java` files).
- Use the JDK's `javac` compiler to compile the source code into bytecode (`.class` files).
2. **Execution with JRE (and JVM)**:
- The JVM, part of the JRE, loads the compiled bytecode (`.class` files).
- The JVM looks for the `main` method to start the program execution.
- The JRE provides the necessary libraries and resources for the JVM to run the program.
### Detailed Steps:
1. **Write Code**:
- Developers write Java code in `.java` files.
2. **Compile Code**:
- The `javac` compiler (part of the JDK) compiles the `.java` files into `.class` files containing Java bytecode.
3. **Run Code**:
- The JVM (part of the JRE) reads and interprets the bytecode in the `.class` files.
- The JVM searches for the `main` method with the correct signature to start the program.
- The JVM executes the bytecode, using the libraries and resources provided by the JRE.
Comments
Post a Comment