[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[school-discuss] Portable DOS script for Java applications



Hello all, 
 
I've developed a portable DOS script for Windows that allows for vlab to run from a shared java JRE on a student's portable USB flash drive, saving space on the small CF drives. With certain jar distributions, either DOS and/or Java.exe have a problem with relative paths (lacking a root drive). To solve this I devised this method to set the DOS path to the JRE subdirectory (absolutely path). Another method would be to use subst.exe (substitute) to virtual mount a subdir as an absolute drive letter. Although less complex the use of subst.exe could lead to drive assignment conflicts in school LAN environments.
 
The method I use would be less offensive to sys admin sensibilities and saves space on USB flash drives. In my usage I've been able to share a JRE between Vlab, GeoGebra, GeoNext, Jmol, Alice, using the Pstart.exe portable applications launcher. The Italian portable applications collections, WinPenPack, use an interesting "X Drive" mechanism to launch applications, it might be more flexible than my clunky DOS scripts.

Hope this helps. -- Lee
 
============================
:: geogebra.cmd
============================
:: set Java application jar file
set APP=geogebra-2.6b.jar

::========================
::Use this DOS script ( .bat or .cmd )
::========================

:: traverse as high to thumb drive's "root" dir as necessary
:: in my case the path looks like this: \apps\math-geogebra, so I need
:: to call ".." twice to go up-folder 2x.

pushd ..\..\

:: parse off the current drive letter & "root path"
:: (nice for testing where you don't have the same directory tree
:: as on the deployed/live Thumb Drive)
:: the path will not include a trailing "\" but that could be
:: concatenated at the end with a \

for /F "eol=; tokens=* delims=+++ " %%1 in ('cd') do set usbbasepath=%%1

:: return to orig. folder/directory
popd

:: temporarily set search path for Java JRE
:: JRE relative path hardcoded here but could be parameterized
:: at beginning of script
set path=%PATH%;%usbbasepath%\apps\shared-jre\jre1.5.0_06\bin

:: Set APP_HOME to the Jmol installation directory.
:: Parse out directory path, use an unlikely delimiter "+++"
:: so that spaces in path don't break path
for /F "eol=; tokens=* delims=+++ " %%1 in ('cd') do set APP_HOME=%%1


:: if the path is empty then use . (current dir)
if "%APP_HOME%x"=="x" set APP_HOME="."

:: build temporary command file
:: this was necessary due to problems with windows environment
:: & start.exe parsing string concatenation

echo start /b /d"%usbbasepath%\apps\shared-jre\jre1.5.0_06\bin\" javaw.exe -Xmx512m -jar "%APP_HOME%\%APP%" > ztmprun.cmd

:: run the temporary command file

ztmprun.cmd