Skip to content

Instantly share code, notes, and snippets.

@shashwata27
Created July 5, 2022 16:19
Show Gist options
  • Save shashwata27/d41f0c01184c8a081f2053896bebb4a8 to your computer and use it in GitHub Desktop.
Save shashwata27/d41f0c01184c8a081f2053896bebb4a8 to your computer and use it in GitHub Desktop.
Switch Java Version from CMD
:: In environment variables set JAVA_HOME as the latest jdk then set PATH as %JAVA_HOME%\bin
@echo off
if "%~1" == "15" (
set "JAVA_HOME=C:\Program Files\Java\jdk-15.0.2"
echo JAVA 15 Activated.
) else if "%~1" == "8" (
set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_331"
echo JAVA 8 Activated.
)
set "Path=%JAVA_HOME%\bin;%Path%"
java -version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment