Created
July 5, 2022 16:19
-
-
Save shashwata27/d41f0c01184c8a081f2053896bebb4a8 to your computer and use it in GitHub Desktop.
Switch Java Version from CMD
This file contains 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
:: 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