bootstrap start Tobias Krais (www.design-to-use.de) How to bootstrap OpenOffice.org?

This method bootstraps OpenOffice.

If you don't want to add all the UNO jars to your classpath do following:

1. Add these files to your jar (you find them in a SDK subfolder):

com/sun/star/lib/loader/Loader$CustomURLClassLoader.class

com/sun/star/lib/loader/Loader.class

com/sun/star/lib/loader/InstallationFinder$StreamGobbler.class

com/sun/star/lib/loader/InstallationFinder.class

com/sun/star/lib/loader/WinRegKey.class

com/sun/star/lib/loader/WinRegKeyException.class

win/unowinreg.dll

2. Create a MANIFEST.MF file for your jar and use it when creating

the jar. The MANIFEST.MF must look like:

Main-Class: com.sun.star.lib.loader.Loader

Name: com/sun/star/lib/loader/Loader.class

Application-Class: my.package.MyClass

Application-Name: my/package/MyClass.class

3. Start your application using e.g. this command:

java -jar myjar.jar

import {%see com.sun.star.comp.helper.Bootstrap}; import {%see com.sun.star.comp.helper.BootstrapException}; import {%see com.sun.star.lang.XMultiComponentFactory}; import {%see com.sun.star.uno.XComponentContext}; /** * This method bootstraps a OpenOffice and returns it's Desktop. * * @return */ public void bootstrapOpenOffice() { XComponentContext xRemoteContext = null; try { // Connect or start a OpenOffice instance xRemoteContext = Bootstrap.bootstrap(); } catch (BootstrapException e) { } // get OO desktop XMultiComponentFactory xRemoteServiceManager = xRemoteContext.getServiceManager(); Object desktop = null; try { desktop = xRemoteServiceManager.createInstanceWithContext( "com.sun.star.frame.Desktop", xRemoteContext ); } catch (Exception e) { } }
Linked resources. Added the hints for usage without classpath. Initial version