Windwos JDK环境变量一键配置
上代码
@echo off
@echo 一键配置jdk环境变量
@echo by wkong、
@echo.
cd /d %~dp0
set mypath=%~dp0
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v JAVA_HOME /t REG_EXPAND_SZ /d %mypath% /f
@echo 设置JAVA_HOME........OK
set tmpClassPath=
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v CLASSPATH /t REG_EXPAND_SZ /d ".;%%JAVA_HOME%%\lib;%%JAVA_HOME%%\lib\tools.jar" /f
@echo 设置ClassPATH........OK
set tmpPath="%Path%;%%JAVA_HOME%%\bin;%%JAVA_HOME%%\jre\bin"
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /d %tmpPath% /f
@echo 添加到Path........OK
@echo 设置JDK环境变量完成,运行java -version查看是否成功
@echo.
pause
直接写到本地install.bat,将bat放到jdk安装目录下,执行即可
如图:
注意文件编码保存为ANSI