Java Architecture Explained: Coding, Compilation, and Execution
Java Architecture
Java architecture explains how a Java program is written, compiled, and executed.The Java architecture is broadly classified into three main stages:
- Coding
- Compilation
- Execution
1. Coding
Coding is the process of writing Java program instructions inside a Java class using the main method.Key points:
A Java program is saved with the .java file extension.
To write Java programs, programmers use editors or Integrated Development Environments (IDEs).
Editor
An editor is software that supports only writing code.
It does not support compilation, execution, or debugging.
Examples of Editors:
IDE (Integrated Development Environment)
- Notepad
- Notepad++
An IDE provides complete support for:
Writing code
- Compiling programs
- Executing programs
- Debugging errors
Examples of IDEs:
- Eclipse
- NetBeans
- IntelliJ IDEA
2. Compilation
Compilation is the process of converting a .java file into a .class file.Key points:
The Java compiler used for compilation is called javac.
The compiler converts Java source code into bytecode.
The generated bytecode is stored inside the .class file.
During compilation:
The compiler checks the syntax of the Java program.
If syntax errors are found, the compiler generates compile-time errors.
If no errors are found, the .class file is successfully created.
Command to compile a Java program:
javac FileName.java
3. Execution
Execution is the process of running the Java program by executing the bytecode of the main method.Key points:
Java program execution is handled by the JVM (Java Virtual Machine).
JVM is part of the JRE (Java Runtime Environment).
JRE is part of the JDK (Java Development Kit).
During execution:
The JVM converts bytecode into machine-specific code.
The machine code is then passed to the operating system.
The output of the Java program is displayed.
If the main method is not found in the .class file, the JVM generates a runtime error.
Command to execute a Java program:
java FileName
Comments
Post a Comment