Created
November 26, 2025 09:37
-
-
Save Vaisakhkm2625/5b831a251a84bb22559c949a5e28f82a to your computer and use it in GitHub Desktop.
swtich java version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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 | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/a/72389151