Enable Java in Apache OpenOffice
Apache OpenOffice uses a Java Virtual Machine to instantiate components written in Java. From OpenOffice.org 2.x on, Java is found automatically during startup, or latest when Java functionality is required. If you prefer to preselect a JRE or JDK, or if no Java is found, you can configure Java using the Tools – Options dialog in Apache OpenOffice and select the section OpenOffice – Java section. In older versions of Apache OpenOffice you can also easily tell the office which JVM to use: launch the jvmsetup executable from the programs folder under the Apache OpenOffice, select an installed JRE or JDK and click OK. Close the Apache OpenOffice including the Quickstarter in the taskbar and restart Apache OpenOffice. Furthermore, open the Tools - Options dialog in Apache OpenOffice, select the section OpenOffice - Security and make sure that the Java enable option is checked.
Using the Java UNO runtime and API in your IDE
Next, the Apache OpenOffice API and Java UNO runtime class files must be made known to the Java IDE.
Prepare the NetBeans IDE
For NetBeans the necessary jar files are made available by simply installing the Apache OpenOffice API Plugin for NetBeans. After the configuration the plugin installs a new library in NetBeans that can be used in projects directly. The library will be automatically added to new projects created with the project wizards coming with the plugin. The following steps show how to install the plugin in NetBeans 5.5 or higher and how to create a new UNO client application project.
- Install and start NetBeans.
- From the Tools menu, select Update center. check mark at least the NetBeans Update Center and press Next. Under Features search for the entry OpenOffice.org API Plugin, select the entry, Add it, press Next, accept the license and follow the next steps to install it completely.
- A plugin specific configuration dialog comes up and required the input of a PATH to a valid office and office SDK installation . After completion of this dialog the plugin is installed and configured correctly.
- If you have a 64-bit machine, use Tools | Java Platforms to register your 32-bit JDK installation.
- From the File menu, select New Project. Select OpenOffice.org category and select the OpenOffice.org Client Application. Follow the next step and finish the project wizard.
- A new project with your specified name is created. The main function of a generated JAVA skeleton contains already the UNO bootstrap function that gives you access to an office context object as main entry point to get started with the Apache OpenOffice API. The context object is from a remote office instance that is connected over a named pipe connection and the default office is started automatically if no instance is running.
- If you have a 64-bit machine, right-click the project name in the project explorer on the left and choose Properties. Click the Libraries Category on the left and use the drop-down box on the right to choose your registered 32-bit Java Platform (JDK), then click the OK button.
- You can now edit, compile, and run your Apache OpenOffice project.
Prepare the Eclipse IDE
For Eclipse the necessary jar files may be made available by defining a User Library.
- Install and start Eclipse.
- From the Window menu, select Preferences. On the dialog window, select Java > Build Path > User Libraries. Press New to create a new User Library. The library's name might be OpenOffice.org Libraries [SDK 3.0.1]. Press OK.
- Select the library and press Add JARs. On the JAR-Selection dialog you should add the necessary libraries. For a standard installation of Apache OpenOffice on unix, these are
- Press OK to save the User Library.
- Add a classpath variable. On the previous dialog window, select Java > Build Path > Classpath Variables. Press New to create a new Variable Entry. A name of the variable might be OO_PROGRAM. A path for a standard installation of 3.2.1 on unix is /opt/openoffice.org/program.
- From the File menu, select New > Java Project. On the wizard's page for Java Settings select the Libraries tab. Press Add Library, select User Library and press Next. Select the User Library you defined before and press Finish. Continue the dialog of the New Project wizard.
A standard installation of Apache OpenOffice on unix is rooted as
/opt. For other installations the libraries should be found at corresponding locations.
Add the API Reference to your IDE
We recommend to add the API and the Java UNO reference to your Java IDE to get online help for the Apache OpenOffice API and the Java UNO runtime. The generated reference documentation provides Javadoc conform index files that can be integrated in most Java IDEs. In NetBeans the IDL reference is automatically integrated with the installation of the OpenOffice API Plugin.
Using the reference in NetBeans is quite simple, type an IDL type in the editor and press+ . A further useful feature is the code completion feature that you get also automatically when you install the plugin.
|Content on this page is licensed under the Public Documentation License (PDL).|