Prerequisites & Setup
Spring Boot is not a first programming course. It is a framework for Java developers, and every lesson uses classes, interfaces, annotations, collections and lambdas without stopping to explain them. A little preparation now saves hours of confusion later.
In this lesson you will check your Java knowledge, install and verify a Java Development Kit (JDK), avoid the most common "two Javas" problem, and set up the tools you need to build and test web APIs.
Java skills you need
You should be comfortable with the topics below. If any of them feels new, spend a day on the linked lesson from the Java tutorial first.
| Skill | Why Spring Boot needs it | Revise it here |
|---|---|---|
| Classes, objects, constructors | Spring creates your objects through constructors | Constructors |
| Interfaces | Services and repositories are interfaces | Abstract Classes & Interfaces |
| Records and enums | Request and response data are often records | Records & Enums |
| Collections and generics | List<Player>, Optional<Player>, Map<String, Integer> | Collections & Generics |
| Lambdas and streams | Security rules, filters and queries use them | Lambdas & Functional Interfaces |
| Exceptions | Errors become HTTP responses | Exceptions |
| Maven or Gradle basics | Every Spring project is a Maven or Gradle project | Maven & Gradle |
You also need basic web knowledge: what an HTTP request and response are, methods such as GET and POST, status codes such as 200 and 404, and the JSON format. The lesson How Web Apps Work explains these ideas, and they are the same in every language. For the database lessons, simple SQL from the SQL tutorial helps.
Here is a quick self-test. If you can read this program and predict its output, you are ready:
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
public class ReadinessCheck {
record Player(String name, String city, int runs) {}
interface Greeter {
String greet(String name);
}
public static void main(String[] args) {
List<Player> squad = List.of(
new Player("Aarav", "Pune", 412),
new Player("Priya", "Pune", 288),
new Player("Kabir", "Mumbai", 351));
Map<String, Integer> runsByCity = squad.stream()
.collect(Collectors.groupingBy(Player::city, TreeMap::new,
Collectors.summingInt(Player::runs)));
System.out.println(runsByCity);
Greeter greeter = name -> "Welcome to the nets, " + name + "!";
System.out.println(greeter.greet(squad.get(0).name()));
}
}{Mumbai=351, Pune=700}
Welcome to the nets, Aarav!The stream groups players by city and adds their runs, and TreeMap keeps the cities in alphabetical order. The lambda implements the one-method Greeter interface.
Install a JDK
Spring Boot 4.1 needs Java 17 or later and is tested up to Java 27. Install Java 25, the current long-term support (LTS) release, unless your company or college uses another version. Free, good builds include Eclipse Temurin, Oracle OpenJDK, Amazon Corretto and BellSoft Liberica; they all behave the same for this course. The Java install lesson walks through the installer on Windows, macOS and Linux.
Every example in this course was run on Java 21 and uses no feature newer than that, so Java 21 or 25 both work.
After installing, open a new terminal and check two things: the java command and the JAVA_HOME environment variable.
java -version
echo $JAVA_HOME # Windows PowerShell: echo $env:JAVA_HOMEopenjdk version "21.0.12.1" 2026-08-18 LTS OpenJDK Runtime Environment Temurin-21.0.12.1+1 (build 21.0.12.1+1-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.12.1+1 (build 21.0.12.1+1-LTS, mixed mode, sharing) C:\tools\jdk-21.0.12.1+1
JAVA_HOME must point to the JDK folder (the one that contains bin). Maven and Gradle use JAVA_HOME, while your terminal uses whichever java comes first on the PATH.
The "two Javas" problem
Many Windows laptops have an old Java 8 left behind by a banking or government utility. If that old java is first on the PATH, you get this error when you run a Spring Boot 4 application:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Class file version 61 means Java 17, and 52 means Java 8. The message says: "this code needs Java 17, but you started it with Java 8." The build may even succeed, because Maven used JAVA_HOME, and only java -jar fails. The fix is to put %JAVA_HOME%\bin (Windows) or $JAVA_HOME/bin (macOS, Linux) before other Java folders in your PATH, or remove the old Java, then open a new terminal and check java -version again.
Maven and Gradle: no installation needed
Every project you create in this course contains a wrapper: the scripts mvnw and mvnw.cmd for Maven, or gradlew and gradlew.bat for Gradle. The first time you run a wrapper, it downloads the right build-tool version into your home folder. You do not install Maven or Gradle yourself.
./mvnw -v # Windows: .\mvnw.cmd -vApache Maven 3.10.0 (c43a36b8d67be7e0805a411bc0898af1a51f5472) Maven home: C:\Users\...\wrapper\dists\apache-maven-3.10.0\dae9a06d Java version: 21.0.12.1, vendor: Eclipse Adoptium, runtime: C:\tools\jdk-21.0.12.1+1 Default locale: en_IN, platform encoding: UTF-8, time zone: Asia/Calcutta OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"
(The Maven home path is shortened here.) The Java version line shows which JDK Maven will compile with. If it says 1.8 or 11, fix JAVA_HOME before going further.
An IDE and an HTTP client
You can write Spring Boot code in any editor, but an IDE that understands Spring saves a lot of typing and catches mistakes early. Popular choices are IntelliJ IDEA, Eclipse with the Spring Tools plugin, and VS Code with the Java and Spring Boot extension packs. Open the project folder (the one with pom.xml or build.gradle) and the IDE imports it.
To test APIs you need an HTTP client. This course uses curl because it is already installed on Windows 10 and later, macOS and Linux, and it shows exactly what is sent and received. In Windows PowerShell, type curl.exe, because curl there is an alias for a different command. Graphical tools such as Postman and the HTTP client built into IntelliJ IDEA are fine too.
When the course shows a raw HTTP request, it looks like this:
POST /api/players HTTP/1.1
Host: localhost:8080
Content-Type: application/json
{"name": "Isha Kale", "role": "BOWLER", "age": 14, "city": "Pune"}Each line maps to a curl option: the method (-X POST), the URL, a header (-H "Content-Type: application/json") and the body (-d '...').
Later lessons also use a database (H2 needs no installation; MySQL or PostgreSQL are optional) and, near the end, Docker. You can install those when you reach them.
Common mistakes
- Installing only a JRE. You need a full JDK (it includes
javac). Modern JDK downloads always include it. - Old terminal windows. Environment variables are read when a terminal opens. After changing
PATHorJAVA_HOME, open a new one. JAVA_HOMEpointing atbin. It should be the JDK folder itself, for exampleC:\tools\jdk-21.0.12.1+1, not...\bin.- Using
curlin Windows PowerShell. It runsInvoke-WebRequestwith different options; usecurl.exe.
Key points
- Learn Java classes, interfaces, records, collections, lambdas and exceptions before Spring Boot.
- Spring Boot 4.1 needs Java 17 or later; install Java 25 LTS if you can choose.
- Check both
java -versionandJAVA_HOME; anUnsupportedClassVersionErrormeans an older Java started your app. - Projects include Maven or Gradle wrappers, so you do not install a build tool.
- Use an IDE that understands Spring, and
curl(orcurl.exeon Windows PowerShell) to test APIs.
Exercise
Prepare your computer for the rest of the course:
- Run
java -versionandjavac -versionand write down both versions. - Print
JAVA_HOMEand check that the folder containsbin\java.exe(Windows) orbin/java. - Run
curl https://spring.io(orcurl.exein PowerShell) and check that you get HTML back. - Explain in one sentence what
class file version 65.0would mean in an error message, given that 61 is Java 17.
Show solution
java -version
javac -version
echo $JAVA_HOME
ls "$JAVA_HOME/bin" # Windows PowerShell: dir $env:JAVA_HOME\bin
curl https://spring.ioBoth commands should report the same major version, 17 or later. If java and javac differ, two JDKs are on your PATH; fix the order. Each Java release adds one to the class file version, so 65.0 means Java 21: the code was compiled for Java 21 and needs Java 21 or newer to run.
Quick Quiz
1. What is the minimum Java version for Spring Boot 4.1?
Spring Boot 4.1 requires Java 17 or later; Java 25 LTS is the recommended choice.
2. mvnw package works, but java -jar fails with UnsupportedClassVersionError. What is the most likely cause?
Maven used JAVA_HOME, but the terminal ran an older java that cannot read Java 17 class files.
3. Why do you not need to install Maven separately?
mvnw and gradlew download and run the build-tool version the project expects.
4. In Windows PowerShell, which command runs the real curl program?
In Windows PowerShell, curl is an alias for Invoke-WebRequest; curl.exe runs the real curl.
Learn Spring Boot with a mentor
Free lessons get you started. Our Full Stack Web Development training adds real projects and code reviews from working developers.
- Project-based learning
- Mentor code reviews
- Free counselling call
