Java版本切换
在A:\DevEnvironment\javaVersion
目录下,创建Windows命令脚本
Java8.bat
@echo off
set JAVA_HOME=A:\DevEnvironment\jdk-1.80_152
set Path=%JAVA_HOME%\bin;%Path%
echo Version has been switched to Java 8.
Java11.bat
@echo off
set JAVA_HOME=A:\DevEnvironment\jdk-11.0.16.1
set Path=%JAVA_HOME%\bin;%Path%
echo Version has been switched to Java 11.
java17.bat
@echo off
set JAVA_HOME=A:\DevEnvironment\jdk-17.0.6
set Path=%JAVA_HOME%\bin;%Path%
echo Version has been switched to Java 17.
将脚本的路径,配置在环境变量上
A:\DevEnvironment\javaVersion
效果
C:\Users\su>java17
Version has been switched to Java 17.
C:\Users\su>java -version
java version "17.0.6" 2023-01-17 LTS
Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing)
C:\Users\su>java8
Version has been switched to Java 8.
C:\Users\su>java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
1
标签:11,set,JAVA,17,switched,been,echo,Java From: https://www.cnblogs.com/xuanstudy/p/17297144.html