Enable Java in OpenOffice.org
OpenOffice.org uses a Java Virtual Machine to instantiate components written in Java. From OpenOffice.org 2.0 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 OpenOffice.org and select the section OpenOffice.org – Java section. In older versions of OpenOffice.org you can also easily tell the office which JVM to use: launch the jvmsetup executable from the programs folder under the OpenOffice.org, select an installed JRE or JDK and click OK. Close the OpenOffice.org including the Quickstarter in the taskbar and restart OpenOffice.org. Furthermore, open the Tools - Options dialog in OpenOffice.org, select the section OpenOffice.org - Security and make sure that the Java enable option is checked.
Using the Java UNO runtime and API in your IDE
Next, the OpenOffice.org 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 OpenOffice.org 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 OpenOffice.org 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 OpenOffice.org 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 OpenOffice.org 3.0.1 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 OpenOffice.org 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 OpenOffice.org 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.org API Plugin.
Using the reference in NetBeans is quite simple, type an IDL type in the editor and press ALT ＋ F1. 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).|