装了很多jdk版本,ant时发现修改环境变量无效,一直是1.7,
1、要改注册表(前提jdk路径配置正确)
2、要改path下的文件
直接运行一下bat
@echo off
:init
set JAVA_HOME_1_7=E:Progra~1Javajdk1.7.0_45_32bit
set JAVA_HOME_1_6=E:Progra~1Javajdk1.6.0_45
:start
echo current JKD VERSION:
java -version
ping 127.0.0.1 -n 2 -w 1000 > nul
echo.
echo =============================================
echo select jdk version
echo 7
echo 6
echo =============================================
:select
set /p opt=select jdk version:
if %opt%==7 (
start /I /WAIT /B wmic ENVIRONMENT where name='JAVA_HOME' set VariableValue="%JAVA_HOME_1_7%" >nul
rem reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment" /v JAVA_HOME /t reg_sz /d "%JAVA_HOME_1_7%" /f
reg add "HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment" /v CurrentVersion /t reg_sz /d 1.7 /f
copy %JAVA_HOME_1_7%binjava.exe %windir%system32java.exe
copy %JAVA_HOME_1_7%binjavaw.exe %windir%system32javaw.exe
copy %JAVA_HOME_1_7%binjavaws.exe %windir%system32javaws.exe
goto success
)
if %opt%==6 (
start /I /WAIT /B wmic ENVIRONMENT where name='JAVA_HOME' set VariableValue="%JAVA_HOME_1_6%" >nul
rem reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment" /v JAVA_HOME /t reg_sz /d "%JAVA_HOME_1_6%" /f
reg add "HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment" /v CurrentVersion /t reg_sz /d 1.6 /f
copy %JAVA_HOME_1_6%binjava.exe %windir%system32java.exe
copy %JAVA_HOME_1_6%binjavaw.exe %windir%system32javaw.exe
copy %JAVA_HOME_1_6%binjavaws.exe %windir%system32javaws.exe
goto success
)
echo error version, check again!
PAUSE
goto start
:success
echo.
echo success, done.
PAUSE
Comments | NOTHING