Skip to content

Instantly share code, notes, and snippets.

@Vaisakhkm2625
Created November 26, 2025 09:37
Show Gist options
  • Select an option

  • Save Vaisakhkm2625/5b831a251a84bb22559c949a5e28f82a to your computer and use it in GitHub Desktop.

Select an option

Save Vaisakhkm2625/5b831a251a84bb22559c949a5e28f82a to your computer and use it in GitHub Desktop.
swtich java version
@echo off
set "JAVA8=C:\Program Files\Eclipse Adoptium\jdk-8.0.472.8-hotspot"
set "JAVA21=C:\Program Files\Eclipse Adoptium\jdk-21.0.9.10-hotspot"
set "JAVA17=C:\Program Files\Eclipse Adoptium\jdk-17.0.17.10-hotspot"
if "%~1" == "21" (
set "JAVA_HOME=%JAVA21%"
setx JAVA_HOME "%JAVA21%"
) else if "%~1" == "17" (
set "JAVA_HOME=%JAVA17%"
setx JAVA_HOME "%JAVA17%"
) else (
set "JAVA_HOME=%JAVA8%"
setx JAVA_HOME "%JAVA8%"
)
set "Path=%JAVA_HOME%\bin;%Path%"
java -version
@Vaisakhkm2625
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment