Created
January 5, 2015 13:00
-
-
Save joost-de-vries/201ad06918077f8a01ae to your computer and use it in GitHub Desktop.
Windows script for switching java version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set MY_JAVA_HOME=D:\devtools\jdk1.8.0_25 | |
set SYMLINK_PATH=C:\ProgramData\Oracle\Java\javapath | |
set JAVA_VERSION=1.8 | |
rem set environment variable for user | |
setx JAVA_HOME %MY_JAVA_HOME% | |
rem change default java version in registry | |
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" /v "CurrentVersion" /t REG_SZ /d %JAVA_VERSION% /f | |
rem change the symlinks that oracle jdk adds to path | |
del %SYMLINK_PATH%\java.exe | |
mklink %SYMLINK_PATH%\java.exe %MY_JAVA_HOME%\bin\java.exe | |
del %SYMLINK_PATH%\javac.exe | |
mklink %SYMLINK_PATH%\javac.exe %MY_JAVA_HOME%\bin\javac.exe | |
del %SYMLINK_PATH%\javaw.exe | |
mklink %SYMLINK_PATH%\javaw.exe %MY_JAVA_HOME%\bin\javaw.exe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment