• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu

Java 6 and JDownloader with REXX

Started by jep, 2011.10.09, 19:15:14

Previous topic - Next topic

jep

Hello,

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

Usage:

  • Save it to e.g. javarun.cmd and place it in the java6\bin folder.
    Run it once and it'll create a WPS Program Object in the Command Prompts folder and associate it with .jar-files
  • Double click on a jar file and it'll ask if it should create a Program Object on the desktop for it
    If you place an .ico file next to it with the same base name as the .jar file, it'll create the program object with that icon.
  • It set some configuration code for path and beginlibpath before it run the jar-file.

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!

sXwamp


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