Your technical depth starts here.
Java Fundamentals, JVM Architecture, and First Program
1.1 Module Overview
This module provides the foundation of Java programming. You will learn what Java is, how Java applications compile and execute across the JDK, JRE, and JVM, how to configure your development environment, and how to write and run your first Java program.
By the end of this module, you should be able to:
- Explain what Java is and why it remains a dominant backend language.
- Differentiate between the JDK, JRE, and JVM.
- Describe the Java compilation and bytecode execution pipeline.
- Write, compile, and run your first Java program from the command line.
- Understand the anatomy of the
mainmethod. - Describe core Java design principles: platform independence, security, and automated memory management.
1.2 What is Java?
Definition
Java is a high-level, statically typed, class-based, object-oriented programming language designed for portability, security, scalability, and large-scale distributed application development.
Java programs are compiled into intermediate bytecode rather than platform-specific machine code. This bytecode runs on the Java Virtual Machine (JVM), enabling the principle of "Write Once, Run Anywhere" (WORA).
Where Java is Used
- Enterprise & Backend Services: High-throughput microservices using Spring Boot, Quarkus, and Micronaut.
- Fintech & Banking Systems: Core transaction ledgers, trading platforms, and payment gateways.
- Cloud-Native & Distributed Systems: Apache Kafka, Apache Spark, Hadoop, Elasticsearch, and Cassandra.
- Android App Development: Native Android runtime (ART) builds on Java APIs.
- Embedded & Desktop Systems: Enterprise desktop tooling and IoT gateways.
1.3 Your First Java Program
Source Code (Main.java)
public class Main {
public static void main(String[] args) {
System.out.println("Hello, CodeStudio!");
}
}Step-by-Step Explanation
public class Main: Defines a class namedMain. In Java, every line of executable code must reside inside a class. When a class is declaredpublic, the enclosing file name must exactly match the class name (Main.java).public static void main(String[] args): The standard entry point of every standalone Java application recognized by the JVM.public: Access modifier allowing the JVM to invoke the method from outside the package.static: Indicates the method belongs to the class itself, allowing the JVM to invoke it without instantiating an object first.void: The method returns no value upon completion.main: The designated method name required by the runtime launcher.String[] args: Array of command-line arguments passed into the program.
System.out.println(...): Standard output method.Systemis a built-in final class injava.lang,outis a staticPrintStreammember, andprintlnprints the string followed by a newline.
1.4 Compilation and Execution Pipeline
A .java file does not run directly on host CPU architecture. It goes through compilation and interpretation/JIT compilation.
Source Code (Main.java)
↓
javac Compiler
↓
Bytecode (Main.class)
↓
Class Loader (JVM)
↓
Bytecode Verifier
↓
Execution Engine (Interpreter + JIT Compiler)
↓
Host Machine Hardware (x86_64, ARM64)Compilation and Run Commands
# 1. Compile source into bytecode
javac Main.java
# 2. Inspect generated bytecode class file
ls -la Main.class
# 3. Launch the JVM and execute the main method
java MainOutput
Hello, CodeStudio!1.5 JDK vs JRE vs JVM
Understanding the runtime stack is fundamental for developers and deployment engineers.
| Component | Full Form | Purpose | Includes |
|---|---|---|---|
| JDK | Java Development Kit | Full toolkit to write, compile, and debug Java programs | Compiler (javac), debugger (jdb), archiver (jar), diagnostic tools (jcmd), plus JRE |
| JRE | Java Runtime Environment | Minimum environment required to run compiled Java applications | JVM, core class libraries (rt.jar / modules), runtime configuration |
| JVM | Java Virtual Machine | Abstract computing machine that executes bytecode instructions | Class loader, memory areas (Heap, Stack, Metaspace), Execution Engine (JIT) |
Relationship Hierarchy
+-------------------------------------------------------+
| JDK (Development Kit) |
| [javac, javadoc, jar, jlink, jcmd, debugger] |
| +-------------------------------------------------+ |
| | JRE (Runtime Environment) | |
| | [Core Java Class Libraries (java.base, etc.)] | |
| | +------------------------------------------+ | |
| | | JVM (Virtual Machine) | | |
| | | [Class Loader, Memory, JIT Engine] | | |
| | +------------------------------------------+ | |
| +-------------------------------------------------+ |
+-------------------------------------------------------+1.6 Core Features of Java
| Feature | Technical Meaning |
|---|---|
| Platform Independent | Bytecode executes uniformly on any JVM implementation conforming to the JVM Specification. |
| Object-Oriented | Pure focus on modular classes, encapsulation, inheritance, abstraction, and polymorphism. |
| Strongly Typed | Strict compile-time type verification prevents unexpected memory type mismatches. |
| Automatic Memory Management | Garbage Collector (GC) runs concurrently to reclaim unreferenced heap objects, eliminating manual free(). |
| Robust & Secure | Pointer arithmetic is disallowed; runtime array bounds and type checks eliminate memory corruptions. |
| High Performance | Just-In-Time (JIT) HotSpot compiler dynamically translates frequently executed bytecode loops into native assembly. |
| Built-in Multithreading | Native OS thread abstraction, locks, concurrency utilities, and modern Virtual Threads (Project Loom). |
1.7 Best Practices
- Always name your file identically to your
public class(case-sensitive). - Maintain standard package conventions (
com.company.project.module). - Write meaningful Javadoc comments (
/** ... */) for public APIs. - Keep
mainmethod minimal—use it only to bootstrap application objects. - Prefer explicit command-line compilation checks during local testing before relying on IDE automation.
1.8 Practice Exercises
- Write, compile, and execute a program that prints your name and career target.
- Inspect the bytecode of
Main.classusingjavap -c Main. - Pass two numbers as command-line arguments (
args[0]andargs[1]), parse them withInteger.parseInt(), and print their sum. - Modify the class name in
Main.javatoAppwithout renaming the file, and observe the compilation error. - Write a program that displays the active Java version using
System.getProperty("java.version").
1.9 Module Recap
In this module, you learned:
- What Java is and why it excels in enterprise and distributed systems.
- How source code is compiled by
javacinto bytecode and executed by the JVM. - The architectural distinction between the JDK, JRE, and JVM.
- How to structure the
public static void main(String[] args)method. - Why WORA (Write Once, Run Anywhere) and JIT compilation deliver high performance with safety.
