Hi Stephan,
The JNI and Rexx stuff is irrelevant here.  Its as simple as this:

 AppClassLoader   --knows-->  UNO classes (via CLASSPATH)
  |                 directly...
  |
  ...and indirectly...
  |
  v
 ExtClassLoader   --knows-->  your classes (via ext dir)
  |                 directly...
  |
  ...and indirectly...
  |
  v
 BootstrapClassLoader --knows-->  java.lang etc. (hardcoded)
                        directly

If your classes call Class.ForName("someUNOclass", true, ExtClassLoader) (as they do when they simply call Class.ForName("someUNOclass")), that wont work.  If your classes want to use UNO, they need to be loaded by a classloader that knows (directly or indirectly) the UNO classes.  Hence, if your classes shall be loaded by ExtClassLoader, the UNO classes would need to be loaded by ExtClassLoader, too.
thank you for your comment.

Did find a solution that solved my problem (BSF4Rexx can now be used as an optional Java extension, making setup/installation considerably easy; also I am putting the OOo-support into the base package).

Just as a little teaser (it still is in beta), here is some ooRexx code that uses the writer component and which runs unchanged on Windows and Linux (the tilde ~ is the message operator, left of it is the receiving object, right of it the name of the message):
   /* create a desktop object, request the XDesktop interface from it and
      request the XComponentLoader interface from that                        */
componentLoader = UNO.createDesktop()~XDesktop~XComponentLoader

   /* use the XComponentLoader interface function "loadComponentFromUrl()" to
      create a writer component (= word processor document)                   */
writerComponent = componentLoader~loadComponentFromURL("private:factory/swriter", "_blank", 0, .UNO~noProps)

   /* get the XTextDocument interface from the writerComponent and use its function
      getText() to get a hold of the text object                              */
text = writerComponent~XTextDocument~getText

   /* set the text of the text object to salute the world                     */
text~setString("Hello OpenOffice.org/StarOffice, this is ooRexx speaking! ("date("S") time()")")

::requires UNO.CLS   /* directive to get the UNO support for ooRexx, defines utility classes, routines */
  
This now runs with BSF4Rexx as a Java extension on both tested operating systems from the command line.

---

The following is the skeleton Rexx script in OOo for the scripting framework ("template.rex"):
/* Hello World in ooRexx, cf. http://www.ooRexx.org, version: 2006-01-06 */
xScriptContext=uno.getScriptContext()     -- get the xScriptContext object

oDoc=xScriptContext~getDocument           -- get the document service (an XModel object)
-- oDesktop=xScriptContext~getDesktop           -- get the desktop (an XDesktop object)
-- oContext=xScriptContext~getComponentContext  -- get the context(an XComponentContext object)

xTextDoc=oDoc~XTextDocument               -- get the XTextDocument interface from the document
hello="Hello World (in ooRexx) "          -- define text to add
xTextDoc~getText~getEnd~setString(hello)  -- add text at the end of the text document


::requires UNO.CLS   -- load UNO support for OpenOffice.org
  
That script also runs on both operating systems successfully for a writer document.

Regards,

---rony

P.S.: One item on the todo list is to automate the installation of "ScriptProviderForooRexx.jar", which I will tackle when I come back from an external ski-seminar in Styria (they have *great* snow and I will be able to ski in Schladming; starting in the late afternoon until midnight there will be presentations and discussions, one presentation talking about creating nutshell scripts for OOo 2.0 using the OOo scripting framework).

P.P.S.: Here is a link to a work of a student who created nutshell examples for ooRexx-OOo scripts: <http://wi.wu-wien.ac.at/rgf/diplomarbeiten/index.html#bakk_07>.


Reply via email to