Foundation
01 — Getting Started
Previous: 00 Index · Next: 02 Variables & Types
New here? If you have not installed the JDK, downloaded the project, or set up an IDE yet, complete Environment Setup first — everything you need is on this site.
What you need
| Tool | Purpose |
|---|---|
| JDK 21+ | Compiler (javac) + runtime (java) |
| Terminal | Run commands |
| This project | All lessons with runnable examples |
Check your install:
1java -version2javac -versionYou should see version 21 or higher (25 works too).
Your first program
Every Java app starts with a class and a main method — the entry point.
1public class Hello {2 public static void main(String[] args) {3 System.out.println("Hello, Java!");4 }5}▶️ java pkg0intro/intro1AboutJava.java · java pkg1core/core1HelloWorld.java
1java pkg0intro/intro1AboutJava.java2java pkg1core/core1HelloWorld.java💡 Key idea: The file name must match the public class name (Hello.java → class Hello).
How this project is organized
1pkg0intro → What is Java? (start here)2pkg1core → Language fundamentals (core1 → core28)3pkg2versions → Java 5 through 21 features4pkg3–pkg4 → Data structures & algorithms5pkg5leetcode → Interview coding problems6pkg6–pkg20 → JVM, concurrency, I/O, databases, testing…7docs/02-learn/ → These tutorials (read in order)8docs/03-interview/ → Interview Q&A (use later)Each class is self-contained — open one file, run it, learn one concept.
Two ways to run code
1. Single-file launch (easiest)
1java pkg1core/core1HelloWorld.javaNo javac step — Java compiles and runs in one command (Java 11+).
2. Compile then run (classic)
1javac -d out pkg1core/core1HelloWorld.java2java -cp out pkg1core.core1HelloWorldNote: package name in the -cp command (pkg1core.core1HelloWorld).
The compile → run pipeline
1YourCode.java ──javac──► YourCode.class (bytecode)2 │3 java (JVM)4 ▼5 Program outputRead the full picture in 01-orientation/01-TutorialAndHistory.md.
⚠️ Common mistakes
| Mistake | Fix |
|---|---|
java Hello without compiling (classic mode) |
Use java Hello.java or compile first |
| File name ≠ class name | Rename file or class to match |
| Wrong directory | Run from project root JavaMastery/ |
Missing semicolon ; |
Every statement ends with ; |
Practice
- Run
intro1AboutJava,intro2HistoryOfJava,intro3Objectives. - Run
core1HelloWorldand change the printed message. - Add a second
System.out.printlnline.
Next → 02 Variables & Types
Source named in this chapter
- intro1AboutJavapkg0intro/intro1AboutJava.java
- core1HelloWorldpkg1core/core1HelloWorld.java