windows下 两个版本的JDK环境变量进行切换

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

@echo off 

:init 
set JAVA_HOME_1_7=C:\Program Files\Java\jdk1.7.0_22 
set JAVA_HOME_1_6=D:\Program Files\Java\jdk1.6.0_27 
set Eclipse_EXE=D:\Tools\DEV(eclipse3.3)\eclipse.exe 

:start 
echo JDK 版本: 
java -version 
ping 127.0.0.1 -n 2 -w 1000 > nul 
echo. 
echo ============================================= 
echo jdk版本列表 
echo 1.7 
echo 1.6 
echo ============================================= 

:select 
set /p opt=请选择jdk版本: 
if %opt%==1.7 ( 
  start  /I /WAIT /B wmic ENVIRONMENT where name='JAVA_HOME' set VariableValue="%JAVA_HOME_1_7%" >nul 
rem reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v JAVA_HOME /t reg_sz /d "%JAVA_HOME_1_7%" /f 
  goto success 
) 
if %opt%==1.6 ( 
    start /I /WAIT /B wmic ENVIRONMENT where name='JAVA_HOME' set VariableValue="%JAVA_HOME_1_6%" >nul 
rem	reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v JAVA_HOME /t reg_sz /d "%JAVA_HOME_1_6%" /f 
    goto success 
) 
echo 选择的版本错误,请重新选择! 
PAUSE 
goto start 

:success 
echo. 
echo 设置环境变了成功. 
ping 127.0.0.1 -n 2 -w 1000 > nul 
taskkill /f /im eclipse.exe 
ping 127.0.0.1 -n 3 -w 1000 > nul 
start %Eclipse_EXE%