Lesson 2: Setting up Your Environment: JDK, JRE, and IDE
To write and run Java code, you need specific tools.
1. Understanding JDK, JRE, and JVM
- JVM (Java Virtual Machine): The component that executes Java bytecode. It's the core of Java's platform independence.
- JRE (Java Runtime Environment): Includes the JVM, plus the core libraries and necessary files to run Java applications. If you only want to run a Java program, you need the JRE.
- JDK (Java Development Kit): The full development kit. It includes the JRE and vital development tools like the compiler (
javac) and debugger. As a developer, you need the JDK.
2. Installation Steps (JDK)
-
Download the latest long-term support (LTS) version of the JDK (e.g., Java 17 or 21) from Oracle or OpenJDK providers.
-
Follow the installation prompts.
-
Verification: Open your command line (Terminal/CMD) and type:
bash java -version javac -version
If you see version numbers, the JDK is installed correctly.
3. Choosing an Integrated Development Environment (IDE)
An IDE dramatically simplifies coding, compiling, debugging, and project management.
| IDE | Best For | Notes |
|---|---|---|
| IntelliJ IDEA (Community Edition) | Beginners/Professionals | Highly recommended for modern Java development. |
| Eclipse | Enterprise Development | Long-standing, robust, and free. |
| VS Code | Lightweight Development | Good for quick edits, requires Java extensions. |
Action Item: Download and install IntelliJ IDEA Community Edition and the JDK (if you haven't already).