⬅ Previous Next ➡

Introduction to Java

Introduction to Java: Features, History, JVM/JRE/JDK, Installation, IDEs & Execution Flow
  • Java is a high-level, object-oriented programming language used to build desktop, web, mobile, and enterprise applications.
  • Key Features: platform-independent (Write Once, Run Anywhere), secure, robust, multithreaded, automatic memory management (GC), rich standard library.
  • History: developed at Sun Microsystems (James Gosling) and later maintained by Oracle.
  • JDK (Java Development Kit) = tools to develop Java programs (includes compiler + JRE).
  • JRE (Java Runtime Environment) = environment to run Java programs (includes JVM + libraries).
  • JVM (Java Virtual Machine) runs Java bytecode and makes Java platform-independent.
  • Bytecode is the intermediate compiled code (.class) generated from source code (.java).
  • Install Java: download and install JDK, set environment variables (JAVA_HOME, PATH), verify using java -version and javac -version.
  • IDEs: IntelliJ IDEA, Eclipse, NetBeans, VS Code (with Java extensions) help with coding, building, and debugging.
  • Execution Flow: Write .java → Compile (javac) → .class bytecode → Run (java) on JVM → Output.
// HelloWorld.java
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, Java!");
    }
}

/*
Execution Flow (steps):
1) Compile:
   javac HelloWorld.java
   => Creates: HelloWorld.class (bytecode)

2) Run:
   java HelloWorld
   => JVM loads bytecode, verifies it, executes main() and prints output.
*/
// Quick difference: JVM vs JRE vs JDK (simple note)
// JVM: runs bytecode
// JRE: JVM + libraries (to run apps)
// JDK: JRE + developer tools (javac, jar, jdb, etc.)
⬅ Previous Next ➡