Introduction of Java
Part 1: Introduction to Java
Types of Java Programs :
1. Applet Programs and Application Programs
In this article, we will clearly explain:
-
What is a Java Application Program?
-
What is a Java Applet Program?
-
Differences between Applet and Application
-
ICSE exam-focused explanation
What is a Java Application Program?
A Java Application Program is a standalone program that runs independently on a computer using the Java Virtual Machine (JVM).
These programs contain the main() method and are executed using the command prompt or IDE like BlueJ.
Key Features of Application Programs
✔ Contains public static void main(String args[])
✔ Runs independently
✔ Can take input from user
✔ Uses Scanner class
✔ Mostly used in ICSE syllabus
Example of Java Application Program
📌 This type of program is commonly asked in ICSE practical exams.
What is a Java Applet Program?
A Java Applet is a small Java program that runs inside a web browser or applet viewer. It does not use the main() method.
Applets are mainly used to create:
-
Graphics
-
Animations
-
Drawing shapes
-
Interactive web applications
⚠️ Note: Modern browsers do not support applets, but they are still important for ICSE theory knowledge.
Key Features of Applet Programs
✔ Does NOT contain main() method
✔ Extends Applet class
✔ Uses paint() method
✔ Runs inside browser or applet viewer
✔ Used for graphics and GUI
Example of Java Applet Program
📌 This program displays text in a browser window.
Difference Between Applet and Application (Important for ICSE Exam)
| Basis | Application Program | Applet Program |
|---|---|---|
| Main Method | Required | Not Required |
| Execution | Runs independently | Runs inside browser |
| Package | No need to extend Applet | Must extend Applet |
| Usage | General programs | Graphics & Web-based |
| ICSE Focus | Practical + Theory | Mostly Theory |
Phases of Program Execution in Java
In this article, we will explain all the phases of Java program execution in a simple and exam-oriented way.
What is Program Execution in Java?
Program execution means the process through which a Java program is written, compiled, and finally executed to produce output.
Phases of Program Execution in Java
There are mainly three important phases:
1️⃣ Writing the Java Program (Source Code)
2️⃣ Compilation
3️⃣ Execution
Let’s understand each phase in detail.
1️⃣ Writing the Java Program (Source Code Phase)
In this phase:
-
The programmer writes Java code.
-
The file is saved with
.javaextension. -
The file name must match the class name.
Example:
If class name is:
Then file name must be:
📌 Important ICSE Point: Java is case-sensitive.
2️⃣ Compilation Phase
After writing the program, the next step is compilation.
Compilation is done using:
What happens during compilation?
-
Java compiler (javac) checks for syntax errors.
-
If errors are found → Compilation fails.
-
If no errors → Bytecode file is created.
The compiler creates a file with .class extension.
Example:
📌 Important ICSE Concept:
Java compiler converts source code into Bytecode, not machine code.
3️⃣ Execution Phase
After successful compilation, the program is executed using:
What happens during execution?
-
JVM (Java Virtual Machine) reads the bytecode.
-
JVM converts bytecode into machine code.
-
Output is displayed on screen.
📌 Important ICSE Concept:
JVM makes Java platform independent.
Diagram of Java Program Execution
Why Java is Platform Independent?
Because:
-
Java converts code into bytecode.
-
Bytecode runs on JVM.
-
JVM is available for different operating systems.
That’s why Java follows:
👉 “Write Once, Run Anywhere”
Example of Complete Execution Process
Step 1: Write Code
Step 2: Compile
Step 3: Run
Output:
Common Errors in Program Execution
✔ Syntax Error – Mistake in writing code
✔ Runtime Error – Error during execution
✔ Logical Error – Wrong output due to wrong logic
Difference Between Source Code and Bytecode
Basis Source Code Bytecode Definition Original program written by programmer Code generated after compilation File Extension .java .class Readability Human-readable Not human-readable Created By Programmer Java Compiler (javac) Execution Cannot run directly Executed by JVM Purpose Writing program Running program
| Basis | Source Code | Bytecode |
|---|---|---|
| Definition | Original program written by programmer | Code generated after compilation |
| File Extension | .java | .class |
| Readability | Human-readable | Not human-readable |
| Created By | Programmer | Java Compiler (javac) |
| Execution | Cannot run directly | Executed by JVM |
| Purpose | Writing program | Running program |
What is JVM (Java Virtual Machine)
JVM (Java Virtual Machine) is a virtual machine that runs Java bytecode. When you compile a Java program, it generates bytecode (.class file). This bytecode cannot run directly on your computer. It runs on the JVM.
JVM (Java Virtual Machine) is a virtual machine that runs Java bytecode. When you compile a Java program, it generates bytecode (.class file). This bytecode cannot run directly on your computer. It runs on the JVM.
Main Functions of JVM:
✔ Makes Java platform independent
✔ Manages memory
JVM is responsible for “Write Once, Run Anywhere”.
What is JRE (Java Runtime Environment)?
In Simple Words:JRE = JVM + Libraries
What is JDK (Java Development Kit)?
JDK = JRE + Development Tools
Relationship Between JDK, JRE, and JVM
⬇
Contains JRE
⬇
JRE contains JVM
JRE = JVM + Libraries
Difference Between JDK, JRE, and JVM (ICSE Table Format)
Basis JVM JRE JDK Full Form
Java Virtual Machine
Java Runtime Environment
Java Development Kit
Purpose
Executes bytecode
Runs Java programs
Develops & runs Java programs
Contains
Execution engine
JVM + Libraries
JRE + Compiler
Used For
Running program
Running program
Writing & compiling program
Required By
All Java users
End users
Programmers
| Basis | JVM | JRE | JDK |
|---|---|---|---|
Full Form | Java Virtual Machine | Java Runtime Environment | Java Development Kit |
Purpose | Executes bytecode | Runs Java programs | Develops & runs Java programs |
Contains | Execution engine | JVM + Libraries | JRE + Compiler |
Used For | Running program | Running program | Writing & compiling program |
Required By | All Java users | End users | Programmers |
Main Features of Java
1️⃣ Simple
2️⃣ Object-Oriented
3️⃣ Platform Independent
4️⃣ Secure
5️⃣ Robust
6️⃣ Portable
7️⃣ Multithreaded
8️⃣ Distributed
9️⃣ Dynamic
Features of Java
✔ Object-Oriented✔ Platform Independent
✔ Secure
✔ Robust
✔ Portable
✔ Multithreaded
✔ Distributed
✔ Dynamic
Comments
Post a Comment