The computer must be installed to switch versions of the JDK, you can not use the green package instead.
Copy the following to the newly created text file, the suffix is modified to the bat format, and right-click Run as Administrator
@echo Offrem Switch Java JDK version echo please switch to admin to toggle Echo Current version Java-version:menuecho ============================================= echo Please select the JDK version to switch echo 1:java jdk 1.7echo 2:java jdk 1.8echo 3: cancel Echo =============================================set/p ch= Please select: if "%ch%" = = "1" goto java1.7if "%ch%" = = "2" goto java1.8if "%ch%" = = "3" goto Exitgoto menu:java1.7set java_home=d:\ Java\jdk1.7.0_45set jre_home=d:\java\jdk1.7.0_45\jreset Java_version=1.7goto Exec:java1.8set JAVA_HOME=D:\Java\ Jdk1.8.0_144set jre_home=d:\java\jdk1.8.0_144\jreset java_version=1.8goto exec:execreg Add "HKEY_LOCAL_MACHINE\ Software\javasoft\java Development Kit "/V currentversion/t reg_sz/f/d"%java_version% "REG Add" hkey_local_machine\sof Tware\javasoft\java Runtime Environment "/V currentversion/t reg_sz/f/d"%java_version% "REG Add" Hkey_local_machine\sy Stem\currentcontrolset\control\session manager\environment "/V java_home/t reg_sz/f/d"%JAVA_HOME% "REG Add" HKEY_ Local_machine\system\currentcontrolset\control\session MAnager\environment "/V jre_home/t reg_sz/f/d"%jre_home% "del/f" C:\Windows\System32\java.exe "copy/y"%java_home%\bin \java.exe "" C:\Windows\System32\java.exe "del/f" C:\Windows\System32\javaw.exe "copy/y"%java_home%\bin\javaw.exe "" C:\Windows\System32\javaw.exe "del/f" C:\Windows\System32\javaws.exe "copy/y"%java_home%\bin\javaws.exe "" C \ Windows\system32\javaws.exe "Set java_path=c:\programdata\oracle\java\javapathdel/f"%JAVA_PATH%\java.exe "Mklink" %java_path%\java.exe "%java_home%\bin\java.exe" del/f "%java_path%\javaw.exe" Mklink "%java_path%\javaw.exe" "%JAVA _home%\bin\javaw.exe "del/f"%java_path%\javaws.exe "Mklink"%java_path%\javaws.exe ""%java_home%\bin\javaws.exe " Echo has switched to JDK%java_version%goto Exit:exit
Switch Java JDK version scripts