Switch between JRE 6 and JRE 7

Publicatiedatum
Reacties Geen

I was being hammered with the fact that I needed to switch between JAVA 6 and JAVA 7 depending on the device I was managing. The script below was created on Windows 7 (64 bit) and assumes you did install JRE 6 and JRE 7 in both 32 bit and 64 bit versions.

@ECHO OFF
:VARIABLES
SET JAVA6SRC64=“C:\Program Files\Java\jre6\bin”
SET JAVA6SRC32=“C:\Program Files (x86)\Java\jre6\bin”
SET JAVA7SRC64=“C:\Program Files\Java\jre7\bin”
SET JAVA7SRC32=“C:\Program Files (x86)\Java\jre7\bin”
SET JAVADST64=C:\Windows\System32
SET JAVADST32=C:\Windows\SysWOW64
SET REGKEY=“HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment”
SET REGVAL=“CurrentVersion”

ECHO “Trying to switch to JAVA %1”
IF “%1” "6" ( :JAVA6 SET JAVASRC64=%JAVA6SRC64% SET JAVASRC32=%JAVA6SRC32% REG ADD %REGKEY% /v %REGVAL% /d "1.%1" /f ) ELSE IF "%1" “7” (
:JAVA7 SET JAVASRC64=%JAVA7SRC64% SET JAVASRC32=%JAVA7SRC32% REG ADD REGKEY /v REGVAL /d “1.%1” /f
) ELSE ( ECHO “Variable %1 is not a valid JAVA version!” ECHO “Current version hint:” REG QUERYHKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment” /v CurrentVersion GOTO END
)

:SWITCH
COPY JAVASRC64%\java.exe %JAVADST64
COPY JAVASRC64%\javaw.exe %JAVADST64
COPY JAVASRC64%\javaws.exe %JAVADST64
COPY JAVASRC32%\java.exe %JAVADST32
COPY JAVASRC32%\javaw.exe %JAVADST32
COPY JAVASRC32%\javaws.exe %JAVADST32

:CLEANUP
SET JAVASRC64=”“
SET JAVASRC32=”“

:END

You can download it as well as javaswitch.bat
Just install it to a directory in your PATH like C:\Windows\ and you should be ready.

Usage:
JAVASWITCH 6 will activate JRE 6
JAVASWITCH 7 will activate JRE 7

Warning:
You should close ALL browsers before you switch JRE!

Advertisement:
prevent spam

Medewerker
Categorie ,

Reacties

Op dit artikel kan niet gereageerd worden.

← Ouder Nieuwer →