These are instructions for Windows XP / Java 6 / OpenOffice 3.1.1. I'm sure they can be adapted for other operating systems / platforms.
- Java SDK (I used 1.6.0_15 - get it here)
- OpenOffice (I used 3.1.1 - get it here)
- Open Office SDK (I used 3.0.0 - get it here)
- Netbeans (I used 6.8 - get it here. You could use another IDE if you like)
Firstly I created a new Java Class Library project in Netbeans called OOoApplet. To this I added a single class which I called "OOoBeanViewer.java". I then (lazily) went looking for the example code. I found it on Koders.com here. I cut and pasted this into my OOoBeanViewer.java stub in Netbeans.
In order for this to compile and run I had to add the following dependencies:
- C:\Program Files\OpenOffice.org 3\Basis\program\classes\officebean.jar
- C:\Program Files\OpenOffice.org 3\Basis\program\classes\unoil.jar
- C:\Program Files\OpenOffice.org 3\URE\java\ridl.jar
- C:\Program Files\OpenOffice.org 3\URE\java\jurt.jar
- C:\Program Files\OpenOffice.org 3\URE\java\juh.jar
Because Open Office doesn't really run in the applet (rather we start it, and then redirect its display to the applet) we need so set things up so that the OOoBean knows where to look. This wa the hardest part as the assumption in the docs I could find was that this demo should just work. It didn't for me.
To get it to work I needed to add a Windows environment variable called UNO_PATH and set its value to be the path to the program directory of your OpenOffice install. I set mine to: "C:\Program Files\OpenOffice.org 3\program"
To get this to stick I then had to reboot. A check "echo %UNO_PATH%" at the command line showed that this had worked.
All that was left was to compile and run. This was done simply using Netbeans. The result is a mostly empty Applet window with some buttons down the side. Fear not! You need to create a new document to see what you desire. This is what you get if you select "New Document ... > Text Document":