📅  最后修改于: 2022-03-11 14:52:16.743000             🧑  作者: Mango
@echo off
echo.
IF "%1" == "" GOTO NoParams
IF "%1" == "8" GOTO J8
IF "%1" == "11" GOTO J11
IF "%1" == "latest" GOTO latest
IF "%1" == "-h" GOTO help
IF "%1" == "--help" GOTO help
:NoParams
echo Enter Java version
GOTO options
:help
echo Usage: javaVer [java version]
GOTO options
:: available java versions
:options
echo options: 8, 11, latest.
GOTO exit
:: java 8
:J8
set JAVA_HOME=C:\Program Files\Java\jdk8u282-b08
GOTO activate
:: java 11
:J11
set JAVA_HOME=C:\Program Files\Java\jdk-11.0.10+9
GOTO activate
:: latest java version
:latest
set JAVA_HOME=C:\Program Files\Java\jdk-15.0.2+7
GOTO activate
:: activates the selected java version
:activate
set Path=%JAVA_HOME%\bin;%Path%
echo Java %1 activated.
GOTO exit
:: prints java version
:exit
echo.
echo Current Java version:
java -version