Using the Java UNO runtime and API in your IDE

1. install open office
2.1 in eclipse create a user library: openoffice point to following jars

juh.jar jurt.jar ridl.jar java_uno.jar unoloader.jar unoil.jar

2.2 in eclipse create a OO_PROGRAM variable point to soffice location

3. create a java project, add openoffice library, OO_PROGRAM to this project
classpath

3.1 create a UNO java file

for example:

FirstUnoContact.java

package org.openoffice.test;

public class FirstUnoContact {

    public static void main(String[] args) {
    try {
        // get the remote office component context
        com.sun.star.uno.XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();

        System.out.println("Connected to a running office ...");

        com.sun.star.lang.XMultiComponentFactory xMCF = xContext.getServiceManager();

        String available = (xMCF != null ? "available" : "not available");
        System.out.println("remote ServiceManager is " + available);
    } catch (java.lang.Exception e) {
        e.printStackTrace();
    } finally {
        System.exit(0);
    }
    }
}

4. run it

如果OO是启动的话,输出可能是如下结果:

Connected to a running office …
remote ServiceManager is available


http://wiki.openoffice.org/wiki/Documentation/DevGuide/FirstSteps/Configuration