Spring Boot Installation
Before Orders compiles you need a JDK 21, a build tool (Maven via the wrapper is enough), and an IDE that understands Spring.
Introduction
Before Orders compiles you need a JDK 21, a build tool (Maven via the wrapper is enough), and an IDE that understands Spring. Prefer a version manager such as SDKMAN! over a single system JDK so other projects can pin older releases without breaking this course.
Verify with java -version and ensure the major version is 21. Boot 3.x requires Java 17 as a minimum; this track standardizes on 21 LTS.
You do not need a global Maven install if the project commits mvnw / mvnw.cmd. The wrapper downloads a pinned Maven distribution — that is what CI should use.
Windows, macOS, and Linux all work. Containers come later; first make java and the wrapper succeed on your laptop.
Purpose of this lesson
Install and verify Java 21 (and optionally Maven) so Spring Initializr projects for Orders build without toolchain surprises.
Understanding the topic
Toolchain facts that prevent 'works on my machine' failures.
- JDK vs JRE: you need a JDK to compile. Temurin builds are a common free choice.
- JAVA_HOME: IDEs and some native tools read it; SDKMAN! sets it when you
sdk use. - Wrapper first:
./mvnw -vbeats a random global Maven 3.6 lingering from 2019. - IDE: IntelliJ IDEA (Ultimate or Community + Spring support) or VS Code with Java + Spring Boot extensions.
Step-by-step explanation
- Install SDKMAN! (or an equivalent JDK manager on Windows).
- Install Temurin 21 and select it in the current shell.
- Confirm
java -versionprints 21. - After you generate Orders, run
./mvnw -vand keep using the wrapper.
Syntax reference
macOS / Linux via SDKMAN! Adjust the exact Temurin identifier to what sdk list java shows.
curl -s "https://get.sdkman.io" | bashsource "$HOME/.sdkman/bin/sdkman-init.sh"sdk install java 21.0.4-temsdk use java 21.0.4-temjava -version# openjdk version "21.x.x" ...
Output
openjdk version "21.0.4" 2024-07-16 LTS OpenJDK Runtime Environment Temurin-21.0.4+7 OpenJDK 64-Bit Server VM Temurin-21.0.4+7
Real-world use
Delivery teams pin JDKs in .sdkmanrc, Dev Containers, or CI images so Orders builds are reproducible. A laptop on 17 and a pipeline on 21 will eventually disagree about language features or annotation processing.
Best practices
- Commit
mvnwand.mvn/wrapperfor every Orders service. - Document the required JDK major in the README.
- Use the same major in local, CI, and runtime images.
Common mistakes
- IDE project SDK set to 11 while the terminal uses 21 — Maven from the IDE then fails strange language features.
- Installing only a JRE and wondering why
javacis missing. - Skipping the wrapper and depending on a corporate Maven mirror that is years behind.
Advanced interview questions
Interview Prep
Practice concise answers, then expand each card for the explanation.
1BeginnerQuestionWhat Java version does Spring Boot 3 require?+
Answer
2IntermediateQuestionWhy commit the Maven wrapper?+
Answer
3IntermediateQuestionJDK 21 locally and JDK 17 in the container — what goes wrong?+
Answer
Hands-on exercise
Lab. Print java -version and save the output. If it is not 21, install Temurin 21 and re-check before the Initializr lesson.
Summary
With Java 21 verified, you are ready to scaffold Orders from Spring Initializr and trust the wrapper for every build.