How to switch between the multiple Java versions(JDK) in Windows 11

Опубликовано: 05 Май 2026
на канале: Kavi Coder
314
7

Learn how to manually switch between multiple Java versions on Windows 11 using environment variables and a simple .BAT script! Whether you're a developer working with multiple JDKs or running legacy Java apps, this step-by-step tutorial will show you how to:

✅ Set JAVA_HOME
✅ Update your system PATH
✅ Easily switch between Java versions using a script file

🎯 .BAT Script Example:

@echo off
set "JDK_VERSION=%1"
if "%JDK_VERSION%"=="" (
echo Usage: jdk [21|24]
exit /b 1
)
set "JAVA_HOME=C:\Program Files\Java\jdk-%JDK_VERSION%"
setx JAVA_HOME "C:\Program Files\Java\jdk-%JDK_VERSION%" /m
echo Switched to JDK %JDK_VERSION%

📌 Just change the path to match your installed Java directory.

🔧 Java Versions Used in this Video:
JDK 21
JDK 24

📁 Typical install paths:
C:\Program Files\Java\jdk-21
C:\Program Files\Java\jdk-24

💬 Drop a comment if you have any questions or need help troubleshooting.
👍 Like & subscribe for more Java tips, Windows tricks, and coding tutorials!