Spring Boot Tutorial 0/110 lessons ~6 min read Lesson 4

    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.

    Course progress0%
    Focus
    11 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    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 -v beats 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

    1. Install SDKMAN! (or an equivalent JDK manager on Windows).
    2. Install Temurin 21 and select it in the current shell.
    3. Confirm java -version prints 21.
    4. After you generate Orders, run ./mvnw -v and keep using the wrapper.

    Syntax reference

    macOS / Linux via SDKMAN! Adjust the exact Temurin identifier to what sdk list java shows.

    bash
    curl -s "https://get.sdkman.io" | bash
    source "$HOME/.sdkman/bin/sdkman-init.sh"
    sdk install java 21.0.4-tem
    sdk use java 21.0.4-tem
    java -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 mvnw and .mvn/wrapper for 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 javac is 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.

    3 questions
    1BeginnerQuestionWhat Java version does Spring Boot 3 require?+

    Answer

    Java 17 as the baseline. This course uses Java 21 LTS for new Orders services.
    2IntermediateQuestionWhy commit the Maven wrapper?+

    Answer

    It pins the Maven version per project so local and CI builds match without requiring a global install.
    3IntermediateQuestionJDK 21 locally and JDK 17 in the container — what goes wrong?+

    Answer

    You may compile language features or dependency bytecode that the runtime cannot load, or you may miss bugs that only appear on the older runtime. Align majors.

    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.

    Ready to mark this lesson complete?Track your journey across the entire course.