/* test.rexx */ /* global variables: ----------------- launchername name of this REXX program that's running appname name of the application propfilename name of the application's .lax property file */ /* main */ parse arg CMD_LINE_ARGUMENTS if (strip(CMD_LINE_ARGUMENTS)\=="") then CMD_LINE_ARGUMENTS = " " || CMD_LINE_ARGUMENTS call setup call setfilenames call displayinfo call parseprops call setuplauncher if (strip(ENVIRONMENT_LAXDEBUG)\=="") then call outputdebug call launch exit /* various initialization things */ setup: call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs' call SysLoadFuncs ENVIRONMENT_CLASSPATH = "" ENVIRONMENT_CLASSPATH = value('CLASSPATH',,'OS2ENVIRONMENT') ENVIRONMENT_LAXDEBUG = "" ENVIRONMENT_LAXDEBUG = value('LAX_DEBUG',,'OS2ENVIRONMENT') /* ENVIRONMENT_LAXDEBUG = "on" */ ENV_CUR_DIR = "" ENV_CUR_DIR = directory() /* ENV_CUR_DIR = "d:\desktop\rexx" */ lax.stdout.redirect = "" lax.nl.os2.java.compiler = "" lax.class.path = "" lax.nl.java.option.java.heap.size.initial = "" lax.nl.java.option.java.heap.size.max = "" lax.nl.java.option.java.stack.size.max = "" lax.nl.java.option.native.stack.max = "" lax.nl.java.option.verbose = "" lax.nl.java.option.verify.mode = "" lax.nl.java.option.garbage.collection.extent = "" lax.nl.java.option.garbage.collection.background.thread = "" lax.nl.java.option.debugging = "" lax.nl.java.launcher.main.class = "" lax.user.dir = "." launchexec = "" launchcompiler = "" launchms = "" launchmx = "" launchoss = "" launchss = "" launchverbose = "" launchverify = "" launchgcextent = "" launchgcbackground = "" launchdebug = "" return /* get this program's name */ setfilenames: /* get this program's name */ parse source os exec launchername interp /* strip off the extension */ lp = lastpos(".",launchername) if lp \= 0 then do launchernamenoextension = left(launchername,lp-1) extension = substr(launchername,lp+1) end else do launchernamenoextension = launchername extension = "" end /* strip off the actual name from the path */ lp = lastpos("\",launchernamenoextension) /* " */ if lp \= 0 then do launcherpath = left(launchernamenoextension,lp-1) appname = substr(launchernamenoextension,lp+1) end else do launcherpath = "." appname = launchernamenoextension end /* get .lax property file name */ propfilename = launcherpath || "\" || appname || ".lax" /* verify that the file exists */ if lines(propfilename) = 0 then /* " */ do say 'Unable to locate' propfilename exit end else nop return /* display startup info */ displayinfo: say "LaunchAnywhere(tm) - The Universal Java Application Launcher" say " version 2.5 - Copyright 1998 Zero G Software, Inc. http://www.ZeroG.com" say "==============================================================================" say "" say "Launching" appname || "..." say "" return /* output debug info */ outputdebug: say "This Launcher: " launchername say "Property file: " propfilename say "Command Line Arguments: " CMD_LINE_ARGUMENTS say "Classpath: " lax.class.path say "Environment Classpath: " ENVIRONMENT_CLASSPATH say "Environment Current Dir: " ENV_CUR_DIR parse source thissource say "Source: " thissource say "" say "Executing these commands:" say "" say "cd " || launcherpath say "cd " || lax.user.dir say "set CLASSPATH=" || launcherclasspath say launchexec || launchcompiler || launchms || launchmx || launchoss || launchss || launchverbose || launchverify || launchgcextent || launchgcbackground || launchdebug || " " || lax.nl.java.launcher.main.class || " " || propfilename || CMD_LINE_ARGUMENTS say "" return /* read and display props file */ parseprops: do while lines(propfilename)=1 parse value linein(propfilename) with l /* " */ if (left(l,1)\=="#") & (strip(l)\=="") then do parse var l prop '=' value evalline = prop || '="' || value || '"' interpret evalline end else nop end return /* setup launcher- prepares to launch java */ setuplauncher: /* determine which java executable, java.exe or javapm.exe */ /* TO DO: if either redirect is set to anything (console or file) then console is turned on. */ /* doesn't handle one or the other, and can't redirect to a file */ if (strip(ENVIRONMENT_LAXDEBUG)\=="") then do lax.stdout.redirect="console" lax.stderr.redirect="console" end if ((lax.stdout.redirect\=="null") & (strip(lax.stdout.redirect)\=="")) | ((lax.stderr.redirect\=="null") & (strip(lax.stderr.redirect)\=="")) then launchexec = "java" else launchexec = "javapm" /* JIT compiler settings */ if (strip(lax.nl.os2.java.compiler)\=="") then launchcompiler = " -Djava.compiler=" || lax.nl.os2.java.compiler else nop /* convert classpath to absolute paths */ rawclasspath=lax.class.path newclasspath="" do while pos(";",rawclasspath) > 0 parse var rawclasspath classpathpiece ';' newrawclasspath rawclasspath = newrawclasspath if (left(classpathpiece,1) == "\") | (substr(classpathpiece,2,2)==":\") then /* Absolute path- do nothing" */ nop else classpathpiece = launcherpath || "\" || classpathpiece /* "prepend the launcherpath */ do while pos("\.",classpathpiece) > 0 classpathpiece = left(classpathpiece, pos("\.",classpathpiece) -1) || substr(classpathpiece,pos("\.",classpathpiece)+2) end if newclasspath=="" then newclasspath = classpathpiece else newclasspath = newclasspath || ";" || classpathpiece end classpathpiece=rawclasspath if (left(classpathpiece,1) == "\") | (substr(classpathpiece,2,2)==":\") then /* Absolute path- do nothing" */ nop else classpathpiece = launcherpath || "\" || classpathpiece /* "prepend the launcherpath */ do while pos("\.",classpathpiece) > 0 classpathpiece = left(classpathpiece, pos("\.",classpathpiece) -1) || substr(classpathpiece,pos("\.",classpathpiece)+2) end if newclasspath=="" then newclasspath = classpathpiece else newclasspath = newclasspath || ";" || classpathpiece /* SYSTEM_CLASSPATH substitution */ sysclpidx = pos("$ENV_CLASSPATH$",newclasspath) if (sysclpidx \= 0) then do lcp = left(lax.class.path,sysclpidx -1) rcp = substr(lax.class.path,sysclpidx+18) newclasspath = lcp || ENVIRONMENT_CLASSPATH || rcp end else nop launcherclasspath=newclasspath /* java initial heap size settings */ if (strip(lax.nl.java.option.java.heap.size.initial)\=="") then launchms = " -ms" || lax.nl.java.option.java.heap.size.initial else nop /* java max heap size settings */ if (strip(lax.nl.java.option.java.heap.size.max)\=="") then launchms = " -mx" || lax.nl.java.option.java.heap.size.max else nop /* java max stack size settings */ if (strip(lax.nl.java.option.java.stack.size.max)\=="") then launchoss = " -oss" || lax.nl.java.option.java.stack.size.max else nop /* java max native stack size settings */ if (strip(lax.nl.java.option.native.stack.max)\=="") then launchss = " -ss" || lax.nl.java.option.native.stack.max else nop /* java verbose classes settings */ if (strip(lax.nl.java.option.verbose)\=="") then select when strip(lax.nl.java.option.verbose)="normal" then launchverbose = " -verbose" when strip(lax.nl.java.option.verbose)="gc" then launchverbose = " -verbosegc" when strip(lax.nl.java.option.verbose)="all" then launchverbose = " -verbose -verbosegc" otherwise nop end else nop /* java verify classes settings */ if (strip(lax.nl.java.option.verify.mode)\=="") then select when strip(lax.nl.java.option.verify.mode)="remote" then launchverify = " -verifyremote" when strip(lax.nl.java.option.verify.mode)="all" then launchverify = " -verify" when strip(lax.nl.java.option.verify.mode)="none" then launchverify = " -noverify" otherwise nop end else nop /* java garbage collection extent settings */ if (strip(lax.nl.java.option.garbage.collection.extent)\=="") then if strip(lax.nl.java.option.garbage.collection.extent)=="min" then launchgcextent = " -noclassgc" else nop /* java garbage collection background settings */ if (strip(lax.nl.java.option.garbage.collection.background.thread)\=="") then if strip(lax.nl.java.option.garbage.collection.background.thread)=="off" then launchgcbackground = " -noasyncgc" else nop /* java remote debugging settings */ if (strip(lax.nl.java.option.debugging)\=="") then if strip(lax.nl.java.option.debugging)=="on" then launchdebug = " -debug" else nop return /* launch the java application */ launch: call directory launcherpath call directory lax.user.dir j=value('CLASSPATH',launcherclasspath,'OS2ENVIRONMENT') "" || launchexec || launchcompiler || launchms || launchmx || launchoss || launchss || launchverbose || launchverify || launchgcextent || launchgcbackground || launchdebug || " " || lax.nl.java.launcher.main.class || " " || propfilename || CMD_LINE_ARGUMENTS j=value('CLASSPATH',ENVIRONMENT_CLASSPATH,'OS2ENVIRONMENT') return