Install JDK (17 / 21 / 23)
The Java Development Kit (JDK) is required to develop and run Spring Boot applications.
Without JDK, you cannot compile Java code, run Spring Boot projects, or use tools like Maven and Gradle.
Spring Boot works best with LTS (Long-Term Support) Java versions.
Which JDK Version Should You Choose?
| JDK Version | Type | Recommendation |
|---|---|---|
| JDK 17 | LTS | Most recommended for Spring Boot |
| JDK 21 | LTS | Latest stable & future-ready |
| JDK 23 | Non-LTS | For learning & testing only |
👉 Best choice:
- Beginners & production apps → JDK 17
- New modern projects → JDK 21
⚠ Avoid using non-LTS versions in production.
Step 1: Download JDK
You can download JDK from trusted providers:
- Oracle JDK
- OpenJDK
- *Eclipse Temurin (Adoptium) Recommended
- Amazon Corretto
👉 Why Eclipse Temurin?
- Free & open-source
- Production-ready
- Widely used in Spring Boot projects
Choose:
- OS: Windows / macOS / Linux
- Architecture: x64 (most common)
- Version: 17 or 21
Step 2: Install JDK
Windows Installation
- Download
.msior.exefile - Double-click and install
- Use default options
- Finish installation
Default path:
C:\\Program Files\\Java\\jdk-17
macOS Installation
Using Installer
- Download
.pkgfile - Open and follow steps
- Installation completes automatically
Default path:
/Library/Java/JavaVirtualMachines/
Linux Installation (Ubuntu Example)
For Java 17:
sudo apt update
sudo apt install openjdk-17-jdk
For Java 21:
sudo apt install openjdk-21-jdk
Step 3: Verify JDK Installation
Run these commands in terminal / command prompt:
java -version
javac -version
Example output:
java version "17.0.10"
If both commands work → JDK is installed correctly.
Step 4: Set JAVA_HOME Environment Variable
Why JAVA_HOME is Important?
- Required by Maven & Gradle
- Required by IDEs (IntelliJ, Eclipse)
- Used internally by Spring Boot
Set JAVA_HOME (Windows)
- Open Environment Variables
- Add new System Variable:
JAVA_HOME = C:\\Program Files\\Java\\jdk-17
- Edit Path → Add:
%JAVA_HOME%\\bin
Set JAVA_HOME (macOS / Linux)
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
Step 5: Verify JAVA_HOME
echo %JAVA_HOME% # Windows
echo $JAVA_HOME # macOS / Linux
Spring Boot & Java Compatibility
| Spring Boot Version | Java Requirement |
|---|---|
| Spring Boot 2.x | Java 8 / 11 |
| Spring Boot 3.x | Java 17+ (mandatory) |
👉 Spring Boot 3 will NOT work with Java 8 or 11.
Common Mistakes to Avoid
- Installing JRE instead of JDK
- Not setting JAVA_HOME
- Using Java 8 with Spring Boot 3
- Multiple Java versions without proper PATH
Best Practices
- Always use LTS versions (17 or 21)
- Verify installation before starting project
- Match Java version with Spring Boot version
- Keep JAVA_HOME correctly configured
Conclusion
Installing the correct JDK is the foundation of Spring Boot development.
For modern Java applications in 2025:
- Use JDK 17 or JDK 21
- Set JAVA_HOME properly
- Verify installation using terminal
Once JDK is installed, your system is ready for Spring Boot, Maven, Gradle, REST APIs, Microservices, and Enterprise applications
