I am a batch scripting god.
After a lot of pain, I managed to create a script which allows me to switch jvm's easily.
For posterity, and my own flex skills, the script:
@echo off
rem set your local path to all the JVM's here.
set jvmdir=c:\code\apps\jvms
if NOT EXIST %jvmdir% goto invaliddir
rem a little bit of manipulation
rem first we remove everything before the jvms dir
call set __temp=%%path:*%jvmdir%\=%%
rem then we determine everything that follows after the next slash
set __lastbit=%__temp:*\=%
rem then we remove that lastbit, leaving only the entire directory and a \ at the end.
call set __currentpath=%%__temp:%__lastbit%=%%
rem then we remove the \ at the end
set __currentjvm=%__currentpath:\=%
if "%~1"=="" goto missingarg
if NOT EXIST %jvmdir%\%1 goto unknowndir
set __currentpath=%jvmdir%\%__currentjvm%
set __replacement=%jvmdir%\%1
call SET path=%%path:%__currentpath%=%__replacement%%%
CALL SET JAVA_HOME=%%JAVA_HOME:%__currentpath%=%__replacement%%%
echo Set path and java home to %1
goto :complete
:missingarg
echo.
echo --^> ERROR!! : Missing argument, which needs to be the jvm directory (%jvmdir%)
echo.
echo Valid dirs:
echo ----------
dir /b /ad %jvmdir%
echo.
echo Current dir: %__currentjvm%
goto complete
:invaliddir
echo.
echo --^> ERROR !! : Setup invalid, we should have a jvmdir but %jvmdir% was not found!
echo.
goto complete
:unknowndir
echo.
echo --^> ERROR !! : Unknown java directory %1, not found in %jvmdir%
echo.
echo Valid dirs:
echo ----------
dir /b /ad %jvmdir%
echo.
:complete
:complete
Reacties
Een reactie posten