📘LESSON 5
3.1 Lesson Outcomes
After completing this lesson, learners will be able to:
- Explain the Java platform.
- Differentiate between Java, Javac, and Bytecode.
- Define Java classes and objects.
- Differentiate between JDK, JRE, and JVM.
- Explain the role of JVM in Java program execution.
3.2 Overview
The Java platform provides the environment required to develop, compile, and execute Java applications. Java programs follow a unique compilation process where source code is converted into bytecode before execution by the Java Virtual Machine (JVM).
This lesson introduces learners to the Java platform and explains the relationship between Java source code, bytecode, classes, objects, JDK, JRE, and JVM.
The Java platform is widely used in:
- enterprise systems,
- web applications,
- Android development,
- cloud computing,
- and software engineering.
Understanding the Java platform is important because it forms the foundation of Java software development and execution.
KT0501 — Overview of Java Platform – An Introduction – Java, Javac, Bytecode
The Java platform provides the tools and environment needed to:
- write Java programs,
- compile Java code,
- and execute Java applications.
Java
Java is a high-level programming language used to create software applications.
Javac
javac
is the Java compiler used to convert Java source code into bytecode.
Bytecode
Bytecode is an intermediate code generated after compilation.
Bytecode is executed by the:
Java Virtual Machine (JVM)
Java Compilation Process
| Step | Process |
|---|---|
| Write Code | Create .java file |
| Compile | javac generates bytecode |
| Execute | JVM runs bytecode |
Example Java Source Code
public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Compilation Command
javac Main.java
Execution Command
java Main
Importance of Java Platform
The Java platform supports:
- cross-platform compatibility,
- software execution,
- and enterprise application development.
KT0502 — Java Class and Object
A class is a blueprint used to create objects.
An object is an instance of a class.
Class Example
public class Student {
String name;
int age;
}
Object Example
public class Main {
public static void main(String[] args) {
Student student1 = new Student();
student1.name = "John";
student1.age = 20;
System.out.println(student1.name);
}
}
Output
John
Importance of Classes and Objects
Classes and objects support:
- object-oriented programming,
- reusable code,
- and software organization.
KT0503 — JDK vs JRE vs JVM
The Java platform contains several important components used during development and execution.
JDK — Java Development Kit
The JDK is a software development kit used to:
- write programs,
- compile source code,
- and develop Java applications.
The JDK includes:
- compiler tools,
- libraries,
- and development utilities.
JRE — Java Runtime Environment
The JRE is a software bundle that allows Java programs to run.
The JRE contains:
- JVM,
- libraries,
- and runtime support files.
JVM — Java Virtual Machine
The JVM is an environment used to execute Java bytecode.
The JVM:
- converts bytecode into machine-level instructions,
- manages memory,
- and executes Java applications.
Comparison of Components
| Component | Purpose |
|---|---|
| JDK | Development kit |
| JRE | Runtime environment |
| JVM | Executes bytecode |
Relationship Between JDK, JRE and JVM
JDK → JRE → JVM
Importance of Java Platform Components
These components support:
- Java development,
- compilation,
- portability,
- and software execution.
3.5 Key Notes / Summary
- The Java platform supports Java application development and execution.
- Java programs are compiled using javac.
- Bytecode is executed by the JVM.
- A class is a blueprint for creating objects.
- Objects are instances of classes.
- JDK supports software development.
- JRE provides runtime support.
- JVM executes Java bytecode.