@echo off setlocal rem 定义 JDK 下载链接和安装路径 set "jdk_url=https://repo.huaweicloud.com/java/jdk/8u151-b12/jdk-8u151-windows-x64.exe" set "jdk_installer=jdk-8u151-windows-x64.exe" set "install_path=C:\Java" rem 创建安装目录 if not exist "%install_path%" mkdir "%install_path%" rem 下载 JDK 安装程序 curl -o "%install_path%\%jdk_installer%" "%jdk_url%" rem 安装 JDK echo Installing JDK... "%install_path%\%jdk_installer%" /s INSTALLDIR="%install_path%" /INSTALLDIRPUBJRE="%install_path%" rem 配置环境变量 setx JAVA_HOME "%install_path%" /M setx PATH "%PATH%;%install_path%\bin" /M echo JDK installation and environment configuration completed. endlocal
复制代码保存bat文件,运行即可.
标签:jdk1.8,set,下载安装,jdk,Windows,rem,JDK,install,path% From: https://www.cnblogs.com/Dmail/p/17584972.html