Hi,

I have a test program written in Java to access OpenOffice functionality 
through UNO.
The program works fine except if it is packed into a jar file.

Running the program directly:

[EMAIL PROTECTED] bin]$ ls -R
.:
TextExtractor.class
[EMAIL PROTECTED] bin]$ java -classpath 
.:/opt/openoffice.org2.0/program/classes/unoloader.jar:/opt/openoffice.org2.0/program/classes/unoil.jar:/opt/openoffice.org2.0/program/classes/jurt.jar:/opt/openoffice.org2.0/program/classes/ridl.jar:/opt/openoffice.org2.0/program/classes/juh.jar
 TextExtractor /tmp/test.xls
Established connecttion to OpenOffice
...

Running the program from the jar file:

[EMAIL PROTECTED] OOUno]$ jar cmf MANIFEST.MF oouno.jar -C bin 
TextExtractor.class
[EMAIL PROTECTED] OOUno]$ jar tf oouno.jar
META-INF/
META-INF/MANIFEST.MF
TextExtractor.class
[EMAIL PROTECTED] OOUno]$ jar xf oouno.jar META-INF/MANIFEST.MF; cat 
META-INF/MANIFEST.MF
Manifest-Version: 1.0
Class-Path: /opt/openoffice.org2.0/program/classes/unoloader.jar /opt/
 openoffice.org2.0/program/classes/juh.jar /opt/openoffice.org2.0/prog
 ram/classes/jurt.jar /opt/openoffice.org2.0/program/classes/ridl.jar
 /opt/openoffice.org2.0/program/classes/unoil.jar
Created-By: 1.5.0_06 (Sun Microsystems Inc.)
Main-Class: TextExtractor
[EMAIL PROTECTED] OOUno]$ java -jar oouno.jar /tmp/test.xls
com.sun.star.comp.helper.BootstrapException: no office executable found!
        at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:253)
        at TextExtractor.main(TextExtractor.java:89)

Following suggestions from this thread I have tried to use the UnoClassLoader 
and give some extra arguments, but nothing works:

[EMAIL PROTECTED] OOUno]$ java 
-Dcom.sun.star.lib.loader.unopath="/opt/openoffice.org2.0/program" -classpath 
.:/opt/openoffice.org2.0/program/classes/unoloader.jar:/opt/openoffice.org2.0/program/classes/unoil.jar:/opt/openoffice.org2.0/program/classes/jurt.jar:/opt/openoffice.org2.0/program/classes/ridl.jar:/opt/openoffice.org2.0/program/classes/juh.jar:/opt/openoffice.org2.0/program
 -jar oouno.jar /tmp/test.xls
com.sun.star.comp.helper.BootstrapException: no office executable found!
        at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:253)
        at TextExtractor.main(TextExtractor.java:89)

Is there a way to allow for packing the client into a jar file and at the same 
time using the simple bootstrap method?

Sincerely,
Hans-Christian Stadler
--------------------------------------

        public static void main(String[] args) {
        try {
                // use uno class loader
                File oobase = new File("/opt/openoffice.org2.0/program");
                ClassLoader classLoader = 
Thread.currentThread().getContextClassLoader();
                ClassLoader unoClassLoader = new UnoClassLoader(oobase.toURL(), 
classLoader);
                Thread.currentThread().setContextClassLoader(unoClassLoader);
                // get the office context
                XComponentContext xContext = Bootstrap.bootstrap();
                assert(xContext.getClass().getClassLoader() == unoClassLoader);
                System.out.println("Established connecttion to OpenOffice");
                XMultiComponentFactory xMCF = xContext.getServiceManager();
                ....
        }
        catch (java.lang.Exception e){
            e.printStackTrace();
        }
    }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to