Developer Guide for NetBeansThis document describes how to set up NetBeans for Office Scripting in Java and how to write a simple script using NetBeans. You can download the NetBeans IDE from the NetBeans download page.
- The Office Scripting module works with NetBeans 3.4
- You should have installed the Office Scripting module during the installation process for the Scripting Framework. If you have not installed it, see the Installation Guide for instructions on how to install.
- On Linux, you will need to ensure that your DISPLAY environment variable is set to <your hostname>:0 in the shell from which you start NetBeans to work around a problem with Java GUIs in Office.
- Create a directory somewhere on your machine in which you will develop your scripts.
Creating a Parcel RecipeOffice scripts are delivered in Script Parcels. Like Office documents they are zip files. Script Parcels have the .sxp extension. Script Parcels are generated from Parcel Recipes where all of the files that are necessary to create the parcel are put together. To create a new Parcel Recipe:
- Right click on your mounted filesystem
- Select New/Office Scripting/Parcel Recipe
- In the New Wizard window that appears you can enter a name for your Parcel Recipe or you can leave it as default
- Click the Finish button to create your Parcel Recipe
Actions available for Parcel RecipeIf the user right clicks on the parcel directory they should be able to use the following actions:
- Compile: Compiles all of the .java files in the Parcel Recipe
- Build: Compiles all of the .java files in the Parcel Recipe. It then introspects on the generated class files and pops up a dialog which allows you to select which methods you wish to export as scripts. Once you have selected the methods to export, it creates a <Parcel Recipe Name>.sxp Script Parcel file in the Parcel Recipe directory. You can configure what files are put into the Script Parcel using the File Filter property.
- Configure: This pops up the Configure dialog, which allows you to select which methods get exported as scripts. Any changes you make in this dialog will only appear in your Script Parcel after you run Build again.
Actions available for Script ParcelsScript Parcels supports only one action:
- Deploy: This will deploy the Script Parcel to an Office Document or to an Office installation. If the Script Parcel already exists in the target, you will be asked whether you want to overwrite.
Note: If you deploy a Script Parcel to an OpenOffice.org installation you need to use the Tools/Refresh User Scripts (Java) menu item for the new script to appear in the Assign Script dialog.
Note: You can also deploy to Office documents within NetBeans using drag and drop or cut and paste.
Actions available for Office DocumentsOffice Documents are also recognised by NetBeans. Any parcels contained in the document will be displayed as nodes of the Office document. Deleting one of these nodes will remove the Script Parcel from the document. Office documents support the standard Delete, Cut and Copy actions and the following custom actions:
- Open: This will open the document in Office using the path
in the Office Settings property to find the Office installation.
If the path to Office is not valid, an error dialog will be popped up informing the user that they need to set their Path to Office Installation property. This setting can be changed by bringing up the Tools/Options dialog and changing IDE Configuration/Server and External Tool Settings/Office Settings
Debugging Office scripts in NetBeans
- Follow the instructions at Debugging Java components in NetBeans/Forte for Java to set up your Office installation to allow debugging of the JVM.
- Start OpenOffice and run one of your Java scripts. This will make sure the JVM is running.
- Attach to Office JVM using the NetBeans Debug/Start Session/Attach... menu option.
- Load a script source in NetBeans and set up breakpoints using Debug/New Breakpoint... menu option.
- Run the script in Office.
If you encounter problems when developing or deploying scripts in NetBeans, one thing you can try is to move your NetBeans settings directory (.netbeans on UNIX, netbeans in Windows - can be found in your home directory) to another name and restart NetBeans.
The Choose Methods to Export as Scripts dialog only displays methods which are defined within class files, it will not display methods in class files which are within jar files in the Parcel Recipe.
If you include package directives in the java source files of your Parcel Recipe, the class files generated when compiling will not get placed in subdirectories reflecting your package directive. This is because the default NetBeans compiler implementation does not use the -d switch to the Java compiler. As a result methods in these classes will not appear in the Choose Methods to Export as Scripts dialog.
Last Modified: Fri Nov 29 14:19:53 GMT 2002