Trainer: Mr. Nantha
DAY 2
This section focuses on the core components essential for running and developing Java applications: the Java Development Kit (JDK), Java Runtime Environment (JRE), Java Virtual Machine (JVM), and Just-In-Time (JIT) . Each plays a crucial role in the execution and performance of Java programs.
What is JDK?
JDK (Java Development Kit) is a software package used to develop Java applications.
In simple terms, the JDK helps us write, compile, and run Java programs.
• It provides the tools needed to create and execute Java applications, including a compiler and other utilities.
• The JDK is used to convert a file with the .java extension (which is human-readable) into a .class file.
• The .class file, also known as bytecode, is not readable by humans.
• A key advantage of the .class file is its platform independence; it can be executed on any operating system.
What is JRE?
JRE (Java Runtime Environment) is used to run Java programs. It provides the resources required for executing Java applications, but does not include development tools for writing or compiling code.
The JRE contains the following components:
• JVM (Java Virtual Machine), which interprets and executes Java bytecode.
• Supporting libraries that provide core functionality for Java applications.
• Runtime files needed for program execution.
The JRE does not include a compiler, so it cannot be used to develop or compile Java programs—only to run them.
What is JVM?
JVM (Java Virtual Machine) is the engine that runs Java programs.
Example:
When we write a Java file:
Sample.java
Compile using JDK
javac Sample.java
This creates:
Sample.class
How Java Code Is Executed
Step 1: Bytecode Generation
After you write and compile a Java program, the compiler generates a .class file. This file contains bytecode, which is an intermediate, platform-independent code.
Step 2: Execution by JVM
The Java Virtual Machine (JVM) reads this bytecode and converts it into machine code that your computer's processor can understand and execute.
Step 3: Platform Independence
By using bytecode and the JVM, Java achieves platform independence. This means you can write your code once, and it will run on any operating system that has a compatible JVM—fulfilling Java's promise of "Write Once, Run Anywhere."
What is JIT?
JIT (Just-In-Time Compiler) is an essential component of the Java Virtual Machine (JVM). It plays a significant role in enhancing the performance of Java applications.
The JIT compiler works by converting bytecode into machine code at runtime. This means that, as the program runs, the JIT compiles sections of bytecode into native machine code, which the computer's processor can execute directly.
Instead of interpreting the code line by line each time it runs, the JIT identifies code that is used frequently and compiles it into native machine code. This process allows the program to execute these portions much more quickly in subsequent runs.
By performing these optimizations at runtime, the JIT compiler significantly improves the execution speed of Java programs.
How They Work Together
1️⃣ We write code → Sample.java
2️⃣ JDK compiles it → Sample.class
3️⃣ JRE provides environment to run
4️⃣ JVM executes bytecode
5️⃣ JIT optimizes performance
Simple Difference Table
Component Purpose
JDK Develop + Compile + Run
JRE Run Java programs
JVM Executes bytecode
JIT Improves performance
Key Takeaways from Day 2
On Day 2, I focused on understanding the essential components of the Java ecosystem. Here are my main takeaways:
JDK (Java Development Kit)
The JDK is specifically designed for development purposes. It provides all the necessary tools, libraries, and resources required to build Java applications.
JRE (Java Runtime Environment)
The JRE is used for running Java programs. It contains the libraries and components needed to execute Java applications, but does not include development tools.
JVM (Java Virtual Machine)
The JVM is responsible for executing bytecode. It acts as the runtime engine that interprets and executes the compiled Java code.
JIT (Just-In-Time Compiler)
The JIT compiler improves performance by converting bytecode into machine code during runtime, allowing for faster execution of Java programs.
Platform Independence
Day by day, I’m building a strong Java foundation before moving deeper into Selenium and Playwright automation.
Top comments (0)