本帖最后由 hoochanlon 于 2023-3-31 20:22 编辑
主要是看了 linux-tutorial-jdk-install.md 和菜鸟教程-Windows 10 配置Java 环境变量,我感觉java配置还是太麻烦了,自己也并不想关心java环境变量的配置。为此简化成一键搞定,从下载安装到配置环境变量,一把梭。
curl -O https://ghproxy.com/https://raw.githubusercontent.com/hoochanlon/ihs-simple/main/d-bat/install_jdk.bat&&call install_jdk.bat
附源码: https://github.com/hoochanlon/ihs-simple/blob/main/d-bat/install_jdk.bat
echo "下载java,并自动安装"
@echo off
:: IF NOT EXIST C:\Users\%USERNAME%\Downloads\java.msi (curl -o C:\Users\%USERNAME%\Downloads\java.msi https://download.oracle.com/java/20/latest/jdk-20_windows-x64_bin.msi)
curl -o C:\Users\%USERNAME%\Downloads\java.msi https://download.oracle.com/java/20/latest/jdk-20_windows-x64_bin.msi
@rem 缓一秒,静默安装java.msi;/S /SP- /VERYSILENT /NORESTART /SUPPRESSMSGBOXES /FORCE
TIMEOUT /T 1&&start /wait C:\Users\%USERNAME%\Downloads\java.msi /quiet /passive
@REM ::----- 配置java环境 -------------------
@REM 设置环境变量
@REM JAVAHOME jdk-20 取值
:: https://download.oracle.com/java/20/latest/jdk-20_windows-x64_bin.msi
setx JAVA_HOME "C:\Program Files\Java\jdk-20;"
@REM PATH
setx PATH "%%JAVA_HOME%%\bin;"
echo "java环境变量配置成功"
@REM :------ 保留项,注释 ---------------------------
@REM %%asd%% 防止转义
@REM CLASSPATH 参考
:: https://blog.csdn.net/weixin_44144786/article/details/119350075
:: setx CLASSPATH ".;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;"
@REM java 手工配置参考
:: https://github.com/dunwu/linux-tutorial/blob/master/docs/linux/soft/jdk-install.md
|