Created
July 2, 2019 05:43
-
-
Save haixinsong/03f7daf70f6989c671e953eeeabab9fd to your computer and use it in GitHub Desktop.
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
| REM https://blog.nediiii.com/jdk-windows-setup/ | |
| @echo off | |
| :start | |
| echo current JDK version: | |
| java -version | |
| echo. | |
| echo ============================================= | |
| echo available JDK version: | |
| echo OpenJDK-8 | |
| echo OpenJDK-11 | |
| echo ============================================= | |
| :select | |
| set /p version=please choose JDK version ( 8 or 11 ): | |
| if %version%==8 ( | |
| echo "choose jdk 8" | |
| )^ | |
| else if %version%==11 ( | |
| echo "choose jdk 11" | |
| )^ | |
| else ( | |
| echo "illegal input, please re-enter;" | |
| goto select | |
| ) | |
| echo ============================================= | |
| REM 为当前会话提供更新的环境变量,仅在当前会话生效 | |
| call SET Path=%%JAVA_HOME_%version%%%\bin;%Path% | |
| call SET JAVA_HOME "%%%%JAVA_HOME_%version%%%%%" | |
| REM 将新的环境变量写入用户变量中,将长期生效 | |
| call SETX JAVA_HOME "%%%%JAVA_HOME_%version%%%%%" | |
| :end | |
| @echo on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment