1) Getting Started
Goal
- Install a JDK
- Compile and run a Java program
- Understand what
javac and java do
Install the JDK (recommended: Java 17 or 21)
- Install a JDK from a reputable provider (e.g., Adoptium Temurin).
- Verify installation:
PowerShell:
java -version
javac -version
If those commands are not found, your PATH is not set.
Your first program
Create a file named Hello.java:
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
Compile:
Run:
What just happened?
javac compiles .java source code into .class bytecode.
java runs bytecode on the JVM (Java Virtual Machine).
Exercises
- Change the message and re-run.
- Print two lines.
- Print your name using
args:
- Run
java Hello Alice and print Alice.
Common mistakes
- File name and public class name must match (
Hello.java and public class Hello).
- Don’t run
java Hello.java (that’s not how the classic compile/run flow works).
Table of contents
- Getting Started: Install, run, and your first program
- Java Basics: types, variables, operators, formatting
- Control Flow: if/switch/loops
- Methods: parameters, return values, overloading
- OOP: classes, objects, encapsulation
- Inheritance & Polymorphism (and when not to use them)
- Interfaces, abstract classes, and design basics
- Exceptions and error handling
- Strings, files, and I/O basics
- Collections: List/Set/Map and Big-O intuition
- Generics (the useful parts)
- Lambdas & Streams
- Dates and time (java.time)
- Testing with JUnit 5 (basics)
- Concurrency: threads, executors, futures
- JVM basics: memory, GC, performance habits
- Build tools: Maven essentials (recommended)
- Next steps: projects to build