- @echo off
- set "JAVA_HOME="
- set /p "JAVA_HOME=Please input value of JAVA_HOME: "
- if not exist "%JAVA_HOME%" (
- echo Not find "%JAVA_HOME%"
- goto :end
- )
- REM For permanent
- reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v JAVA_HOME /t REG_SZ /d "%JAVA_HOME%" /f
- reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PATH /t REG_SZ /d "%JAVA_HOME%;%PATH%" /f
- reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v CLASS_PATH /t REG_SZ /d "%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib" /f
-
- REM For current CMD
- set "PATH=%JAVA_HOME%;%PATH%"
- set "CLASS_PATH=%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib"
-
- REM Verify
- echo,
- echo,PATH=%JAVA_HOME%;%PATH%
- echo,
- echo,CLASS_PATH=%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
- echo,
-
- :end
- pause
复制代码
|