OS2World OLD-STATIC-BACKUP Forum

OS/2 - SIGs => Rexx => Topic started by: jep on 2011.10.09, 19:15:14

Title: Java 6 and JDownloader with REXX
Post by: jep on 2011.10.09, 19:15:14
Hello,

this is my code to start and use JAVA 6 with e.g. JDownloader.

Usage:

Note 1:Please place the attached Java6.ico next to the script in the java6\bin folder
Note 2: Tested with JDownloader, place that attached icon next to the .jar-file with the same name ;)

/* Rexx wrapper to start Java apps */

/* Load RexxUtil Library */
IF RxFuncQuery('SysLoadFuncs') THEN
DO
    CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
    CALL SysLoadFuncs
END

PARSE SOURCE . . myRexxScript
java_dir = STRIP( FILESPEC( 'D', myRexxScript )||FILESPEC( 'P', myRexxScript ), 'T', '\' )

IF wpsObjectExist( '<RUN_JAVA6>' ) = 0 THEN
    rc = SysCreateObject( "WPProgram", "Java 6", "<WP_PROMPTS>", "OBJECTID=<RUN_JAVA6>;EXENAME="||myRexxScript||';PARAMETERS=-jar -Xmx512m "%**P\%**F";ICONFILE='||java_dir||'\java6.ico;ASSOCFILTER=*.jar;' )

PARSE VALUE REVERSE( ARG(1) ) WITH '"'ext'.'app'\'app_path'" m215xmX- raj-'
IF LENGTH( app ) > 0 THEN
DO
    app = REVERSE( app )
    app_path = REVERSE( app_path )
    objID = TRANSLATE( app )
    IF wpsObjectExist( '<WP_'||objID||'>' ) = 0 THEN
    DO
        CALL CHAROUT , 'Do you want to create an object on the desktop for '||app||'? (Y/n)'
        PARSE UPPER PULL answer
        IF answer <> 'N' THEN
            rc = SysCreateObject( "WPProgram", app, "<WP_DESKTOP>", "EXENAME="||myRexxScript||";PROGTYPE=PROG_WINDOWABLEVIO;PARAMETERS="||ARG(1)||";STARTUPDIR="||TRANSLATE( app_path )||";MINIMIZED=YES;OBJECTID=<WP_"||objID||">;ICONFILE="||app_path||"\"||app||".ico;" )
    END
END

CALL VALUE 'PATH', java_dir||';'||VALUE( 'PATH', 'OS2ENVIRONMENT' ), 'OS2ENVIRONMENT'
IF RxFuncQuery( 'SysSetExtLibPath ' ) Then
    'SET BEGINLIBPATH='||java_dir||';%BEGINLIBPATH%'
ELSE
    CALL SysSetExtLibPath java_dir||';'||SysQueryExtLIBPATH( 'B' ), 'B'
JAVA ARG(1)
RETURN rc

/* Code borrowed from REXX Tips & Tricks v3.60 */
wpsObjectExist: PROCEDURE /* parameter: '<new_wps_object_id>', return: 1 exist, 0 doesn't exist, 43 error */
  PARSE ARG objID
  rc = 43               /* init return/error code 43 = routine not found */
  SIGNAL ON SYNTAX NAME ObjectExistError

  IF SUBSTR( objID, 2, 1 ) <> ":" THEN
    IF LEFT( objID, 1 ) <> "<" & RIGHT( objID, 1 ) <> ">" THEN
      objID = "<" || objID || ">"

  /* create the object and see if it fail */
  tempRC = SysCreateObject( "WPFolder", "TestObject", "<WP_NOWHERE>", "OBJECTID=" || objID || ";", "FAIL" )

  IF tempRC = 1 THEN
  DO
    CALL SysDestroyObject objID
    rc = 0
  END
  ELSE
    rc = 1

ObjectExistError:

RETURN rc


REXX can do so much... use it!
Write a dll that both rexx and other apps can use instead of VIO/CLI apps!
Wrap the dll with a rexx script to do what the app does in other OS's!
Title: Re: Java 6 and JDownloader with REXX
Post by: sXwamp on 2011.12.02, 15:09:43

Hi Jep,

Thanks for the Java Rexx script, works great. Keep up the great work and contribution to the community !!!

I was thinking about a Firefox install script.

Any tips on how to do these in Rexx

1) Copy 'firefox' directory to 'firefox-bak' directory

2) Unzip firefox.zip to a temp directory when dropping new firefox.zip file on the FirefoxInstall.cmd file

3) Delete files in 'firefox' directory, execpt firefox.exe (to keep reference to Program object).

4) copy new firefox files to 'firefox' directory and overwriting old firefox.exe.


Cheers,

Greggory