(incubating) | The Free and Open Productivity Suite

Developer's Guide

API

SDK

Tips 'n' Tricks

Miscellaneous

Content for OpenOffice.org version 3.3.

OpenOfficeOpenOffice.org/StarOffice and NetBeans/Forte for Java


Contents

Introduction
Download
Displaying the Office API reference in the IDE
Java Code Completion in NetBeans/Forte
Using makefiles in NetBeans/Forte
Debugging Java components in NetBeans/Forte for Java

Introduction

If you need an integrated development environment (IDE), you should take NetBeans / Forte for Java into account. NetBeans is an open source, modular IDE, written in the Java programming language. Currently it supports Java development, but its architecture lends itself to supporting other languages as well. Since it's written in the Java language, it will run on any platform with a virtual machine.

Both, the Office API reference from the Office Development Kit (ODK) and the integrated development environment NetBeans/Forte are capable tools. In order to benefit from both tools, you can integrate the Office API reference into the integrated development environment. It is also possible to integrate the Office API reference to other Java IDEs, for example JBuilder or Kawa.

Classes can have a lot of data members (sometimes called fields), and member functions (typically called methods). To keep track of all fields and methods of your classes, you can use Netbeans/Forte's Java code completion for your own classes and Java Archives.

Furthermore, in order to compile and execute your programs, you can profit by makefiles.

Download

You can download the index files of the Office API reference from http://api.openoffice.org/servlets/ProjectDownloadList .

In the future, the index files of the Office API reference in the ODK will be adapted to the javadoc standard, so that you do not have to download the mentioned files.

Displaying the Office API reference in the IDE

In order to use the Office API reference in NetBeans/Forte, you should download the compressed file with the needed index files, first. Then you should decompress the file to the directory www/common/ref of your ODK. After decompression you should have a folder index-files.

NetBeans/Forte

Further on, start your IDE NetBeans/Forte, open the Explorer window and choose the tab page Javadoc. Then the directory <ODK>/www/common/ref should be mounted by clicking the right mouse button on the directory "Javadoc" and selecting the entry "Add Directory ...". In the following dialog with the title "Mount Directory", you should select the directory <ODK>/www/common/ref/.

In order to open the Office API reference for a class, method, or property in a Java file, the text cursor should be positioned on the desired word in the Java file. By hitting the keyboard shortcut Ctrl-F1, a window with the title "Javadoc Index Search" will be opened and will show all found occurrences of the Office API reference. Now, you can select your favored entry and the matching Office API reference file will be shown in the frame below.

JBuilder

If you are preferring another IDE than NetBeans/Forte (for example JBuilder, Kawa), the installation of the index-files should be very similar to the described installation for NetBeans/Forte.

In JBuilder, you have to open the window for the project properties (Project->Project Properties) and select the tab for the documentation. Then, you must add the directory <ODK>/www/common/ref.

In order to open the Office API reference for a class, method, or property in a Java file, the text cursor should be positioned on the desired word in the Java file. By hitting the keyboard shortcut F1, a window with the title "JBuilder Help" will be opened and will show all found occurrences of the Office API reference.

Java Code Completion in NetBeans/Forte

If you want to benefit from the Java code completion for your own Java Archives, you should read the following description, an abstract of the NetBeans/Forte IDE help:

"...
The IDE's parser database enables several Source Editor features of the IDE, including Java code completion, Fast Open, Fast Import, Go to Source, Go to Declaration, and Show Javadoc.

By default, the parser database consists of files for the Java 2 SDK, v. 1.3, plus Java Servlet 2.2 and the Ant build tool. If you install the apisupport module, database files for OpenAPIs are also included.

You can update the parser database so that your own classes are among the choices offered when using code completion, Fast Open, Fast Import, and the other features that depend upon the parser database.

To update the parser database:
1. In the Explorer or Object Browser, right-click the package or filesystem containing the classes you want to add to the database. Choose Tools Update Parser Database from the contextual menu. The Update Parser Database dialog box is displayed.

2. Type a file name (with no extension) in the Parser Database File Prefix field of the Update Parser Database dialog box. Use a different prefix for each package or filesystem. Two files are created for each parsed filesystem: <prefix>.jcs, where classes and interfaces are stored, and <prefix>.jcb, where methods and fields are stored.

3. In the Storage Levels panel of the same dialog box, select the level of code for classes, fields, and methods that you want included in the database. For libraries that you cannot edit, you probably want the parser database to
include only protected and public members. For libraries (filesystems) that you are working on, you might want to also include private members. Only static fields and methods are included in the database.

4. Click OK to add the files to the parser database.

You need to manually update the parser database only one time per filesystem. After the first manual update (which defines the parser database files for a filesystem), the database is automatically updated for that filesystem whenever a file is saved or successfully parsed.
If you delete classes or packages, however, they are not automatically removed from the parser database. If you don't want these elements to appear in the code completion box and other features dependent upon the parser database, you can delete the parser database files manually.
..."

Using makefiles in NetBeans/Forte

In order to benefit from makefiles, you can use the module "makefile" (http://makefile.netbeans.org/):
"... This module provides limited support for using make and makefiles within the IDE. Specifically, it causes the IDE to recognize makefiles as something special, let you edit them as text, and use Compile and Execute to run targets on the makefiles. It does not attempt to build makefiles for you; currently it also does not let you run a makefile target when Compile is run on some other source file. Documentation is available from the navigation bar. ..."

You should enable the module "makefile":
"Enabling or Disabling a Module
Disable the modules you don't use to save startup time and memory. (Don't disable the project module, as that might affect the storage of settings.)
To enable or disable a module:
1. From the Tools menu, choose Setup Wizard.
2. Go to the Module Installation pane.
For some configurations of the IDE, you access the Module Installation pane by simply clicking the Next button. For other configurations, you must go to the Select Set of Modules to Install pane, click the Custom Set of Modules radio button, and click the Next button.
3. On the Module Installation pane, select the modules you want to enable or disable and modify their Enabled property.
4. Click Finish."

Debugging Java components in NetBeans/Forte for Java

If you use NetBeans or Forte for Java, you can easily attach to the Java Virtual Machine. Before attaching you should open the appropriate source file into the source editor of NetBeans/Forte for Java and set the breakpoints at will. This requires that the directory containing the source file is mounted. Then you Choose menu Debug->Attach to open the connect dialog. Then select the Java Platform Debugger Architecture (JPDA) and thereafter the connector "SocketAttach (Attaches by socket to other VMs)". Finally, you must enter the computer name and port.

Attaching the debugger to a running office process:

  1. Close every office process.
  2. Search and open the file java.ini (Windows) and javarc (Unix) respectively.
  3. Customize this file by adding the following lines:
    Java=1
    JavaScript=1
    Applets=1
    -Xdebug
    -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n
    The last line effects that the VM listens to port 8000 for a debugger. The VM and hence the office do not block until the debugger connects to the VM.
  4. Invoke your office application.
  5. In NetBeans/Forte for Java, mount the directory, where the source file resides.
  6. Open the source file in the source editor of NetBeans/Forte for Java.
  7. The Attach to VM dialog box enables you to connect the debugger to the office application running on another virtual machine. You open this dialog box by choosing Debug Attach from the main window.
  8. In the Attach to VM dialog box, choose the debugger type "Default debugger (JPDA)".
  9. Then, you must choose the Socket Attach connector. In this context, you must supply the host name of the computer that the Java office application runs on and the number of the port on which the debugged JVM is listening.
  10. Invoke your Java Office component.
  11. Once the debugger connects to the running virtual machine, you will see threads as if you were debugging locally. If you set a breakpoint in the source code, the Source Editor opens with the breakpoint line highlighted in red.

You can find more information on Debugging Java Components.

 


Author: Bertram Nolte ( 2001-11-28 2:14 PM )
Copyright 2001 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, CA 94303 USA. All rights reserved.



Apache OpenOffice is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.

Copyright & License
Apache and the Apache feather logos are trademarks of The Apache Software Foundation. OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.