Skip to content

Building the OpenOffice plugin step by step

John R. D'Orazio edited this page Dec 18, 2020 · 10 revisions

This will guide you through setting up your development environment in order to test a build of the OpenOffice plugin. It is perhaps slightly different than for a standalone Java project, since this Java project depends on the OpenOffice environment.

The process is pretty much the same for LibreOffice, which simply uses it's own SDK. So far the x86 build for Windows is working. As builds are tested and debugged on other platforms more information can be added to this wiki.

  1. Install Apache Open Office and the corresponding AOO SDK. As of the writing of this document, these are 4.1.7. In the meantime version 4.1.8 has been released and is required for the Linux build. You can download the installer here: https://www.openoffice.org/download/index.html (choose your Operating System and click on Download Full Installation; for simplicity in the development environment I suggest choosing the English version, language packs can be added after). From the same page click on the "Software Development Kit" link in the right sidebar (which links here: https://openoffice.apache.org/downloads.html ) and download the SDK with the same version number as the OpenOffice you downloaded.

    • If installing in Ubuntu, if you have downloaded the two tar.gz files to say your /tmp folder, you can install like this:

      cd /tmp
      tar -xvzf Apache_OpenOffice_4.1.8_Linux_x86-64_install-deb_en-US.tar.gz
      tar -xvzf Apache_OpenOffice-SDK_4.1.8_Linux_x86-64_install-deb_en-US.tar.gz
      cd en-US/DEBS
      sudo dpkg -i *.deb
      cd desktop-integration
      sudo dpkg -i *.deb

      By default, this will install/update Apache OpenOffice in your /opt directory (/opt/openoffice4/).

  2. Install the right Java Development Kit for the build :

    • if intending to build on Windows, install JDK 8 (1.8) x86 (can't use x64, OpenOffice is only x86 on Windows, and can't use anything later than JDK 1.8 because 1.8 is the last x86 JDK). A version of at least JDK 8 is required by the libraries that are included in the project. So please install JDK 8 32 bit for the Windows build. Can obtain from here: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html. Select the 'Windows x86' link (download requires creating a free account).
    • if intending to build on Linux or MacOS install JDK 11 (which is x64 by default). Either Oracle JDK or OpenJDK should work. On Ubuntu 18.04 or 20.04: sudo apt-get install openjdk-11-jdk. Previous versions of Ubuntu will probably install OpenJDK 10 with this command, so I would recommend working from Ubuntu 18 or 20, otherwise you will have to download the JDK 11 tar.gz and install manually. Downloading Oracle JDKs will require creating a free account on the Oracle website.
    • For MacOS a 64 bit JDK will be required, since ever since Catalina, the OS is only 64 bit and all applications (OpenOffice and JCEF included) are 64 bit (at least in my understanding, I'm not a Mac user).
  3. Install Netbeans. Which version should you install? The AOO plugin for Netbeans was last built for Netbeans 8, which means that you can install it from inside the Netbeans interface in the Plugins section since it is published to the Netbeans 8 / 8.1 repository. For more recent versions such as Netbeans 11 or 12 the AOO plugin will still work just as well, however you will have to download and install it manually. The OpenOffice plugin for Netbeans is confirmed to work in versions of Netbeans up to 12.1 both on Windows 10 and on Ubuntu 20.04, as long as you aren't using JDK 15 in Netbeans 12.1 or JDK 14 in Netbeans 11.3.

    Apache NetBeans 10 runs on JDK LTS releases 8 and 11, whereas JDK 14 is too recent and can cause problems.

    Apache NetBeans 11.3 runs on JDK LTS releases 8 and 11, whereas JDK 14 is too recent and can cause problems.

    Apache NetBeans 12.1 runs on JDK LTS releases 8 and 11, as well as on JDK 14, whereas JDK 15 is too recent and can cause problems.

    • On Windows go to this page: https://netbeans.apache.org/download/nb121/nb121.html and click on the corresponding download link for Windows.
    • On Ubuntu 20.04 sudo apt-get install netbeans will default to Netbeans 10. Netbeans 10 works with JDK 8 and JDK 11, but probably not JDK 12. The JCEF build for Linux x64 was built with JDK 11, which means you will need Netbeans >= 10. If you want to be on the safe side I would suggest installing Netbeans 11 or 12 manually (note that Netbeans 11 on Linux x64 will not install with JDK 14 set as the default, so make sure that not only JDK 11 is installed but also set as the default! if you don't see Java 11 when issuing java -version then run sudo update-alternatives --config java and choose JDK 11 from the list):
      cd /tmp
      wget https://archive.apache.org/dist/netbeans/netbeans/11.3/Apache-NetBeans-11.3-bin-linux-x64.sh
      chmod +x Apache-NetBeans-11.3-bin-linux-x64.sh
      ./Apache-NetBeans-11.3-bin-linux-x64.sh
      During installation it will ask for the Java environment to use for Netbeans, make sure you specify the path to the JDK 11 on your system (such as /usr/lib/jvm/java-11-openjdk-amd64). Netbeans will be installed to your user folder. If you want to launch netbeans by simply typing "netbeans" from anywhere you also need to create a symlink:
      sudo ln -s ~/netbeans-11.3/netbeans/bin/netbeans /usr/local/bin/netbeans
      Then you can launch netbeans with:
      netbeans &
      (adding the & runs the process in the background so you can still use the terminal while netbeans is running)
  4. Install the AOO plugin for Netbeans. In Netbeans 8 / 8.1 the plugin can be found in Tools -> Plugins -> Available plugins. In more recent versions such as Netbeans 11/12 it will need to be installed manually, please refer to this page: https://wiki.openoffice.org/wiki/OpenOffice_NetBeans_Integration#NetBeans_8.x_and_Apache_OpenOffice_4.1.x

    This page will forward to the download page: http://plugins.netbeans.org/plugin/57917/apache-openoffice-api-plugin

    From here you can download the NBM file which you can then drag onto the running instance of Netbeans in order to install the plugin (at least in Windows 10 and Netbeans 12.1).

    • In Linux you would go to Tools -> Plugins -> Downloaded -> Add plugin and browse to the location of the downloaded nbm file, then Install plugin. It is confirmed to work in Netbeans 10 on Ubuntu 20.04...

    Once the AOO plugin is installed, you will find the settings under Tools -> Options -> Misc -> AOO API Plugin , where you will have to point Installation of Apache OpenOffice to the path of your Open Office installation, and Installation of Apache OpenOffice SDK to the path of your AOO SDK installation:

    • on Windows these are typically C:\Program Files (x86)\OpenOffice 4 and C:\Program Files (x86)\OpenOffice_4.1.7_SDK\sdk
    • on Linux these are typically /opt/openoffice4/ and /opt/openoffice4/sdk/
    • on MacOS these are typically ??? (need confirmation)
  5. If using a version of Netbeans < 11, you will need to install the git plugin for Netbeans (ever since Netbeans 11 this is default functionality and no plugin is needed, as can be seen in Teams -> Git). If you need to install the plugin you can find it here: Tools -> Plugins -> Available plugins -> git. It might help to order the plugins alphabetically to find it better. If the list is empty, go to Tools -> Plugins -> Settings and make sure Netbeans plugins portal is checked, then go back to Tools -> Plugins -> Available plugins and click on Check for newest, the list should populate with a number of results.

  6. Optional: Install a Glassfish server instance in your Netbeans (useful for inspecting the Derby database):

    • Note that Glassfish v5 is only compatible with JDK 8, so you will need JDK 8 installed in order to use the Glassfish server
    • Select Tools -> Servers (or Server Manager) to open the Servers dialog
    • Click Add Server
    • Under Server, select GlassFish v5 and click Next
    • Under Platform Location, browse to or enter the location of your GlassFish Server installation (default on Windows is C:\Users\yourusername\GlassFish_Server\glassfish , default on Linux is ~/GlassFish_Server/glassfish, I just left the default)
    • Click Next
    • Under Domain, use the drop-down list to select an existing domain, type in the path to the domain directly in the field, or type the name of a new domain to create (default on Windows was domain1 for me, I just left the default)
    • Click Finish (you don’t need to enter username or password)

    Once the Glassfish Server is setup, you should be able to find “JAVA DB” among the available libraries. This can be useful if you want to be able to connect to the Derby database from the Netbeans interface (under Services -> Servers and Services -> Databases). If you right-click on "JAVA DB" and select properties, set Java DB installtion to the path for javadb within your GlassFish installation folder, (on Linux for example it would be ~/GlassFish_Server/javadb) and set Database location to ~/.BibleGetOpenOfficePlugin/. (Note that you would need to use the absolute path in your home folder, you will not be able to use the ~ shortcut.) Naturally you will only be able to set this once the BibleGet Database has been created, i.e. after a first test build of the BibleGet plugin. If the database already exists and you have set the properties for Java DB, you should see the BIBLEGET database underneath Java DB, right-click and Connect. If the connection is correctly established, you will see the connection underneath the Drivers folder, where you can expand Other schemas and then BIBLEGET to view the tables that have been created. If you right-click on a table, you can select View Data to inspect the data stored in the table.

    Beware however that I randomly ran into an issue where the Derby service would no longer start in my Netbeans, for no apparent reason. (Actually this could be because I didn't have JDK 8 installed while testing the Linux build!) An alternative to installing Glassfish in Netbeans, is the RazorSQL client which can connect to a Derby database.

  7. As for using the embedded database driver in the actual codebase, I don't believe a version any higher than 10.14.2.0 can be used with JRE 1.8, so the embedded driver found in the derby.jar from Apache Derby 10.14.2.0 here has been included already in the project libraries. Please verify that it is in fact present once you've forked and cloned the project repository in the next few steps.

  8. Fork your own copy of the Github repo: https://github.com/BibleGet-I-O/bibleget-openoffice.git

  9. Clone your forked copy into Netbeans: Team -> Clone and under Remote Repository -> Repository URL paste your forked copy’s repo url, along with your Github user credentials.

  10. Once the project is finished synchronizing from the remote repository, you will have to make sure the necessary libraries are installed. First checkout the development branch that you are going to build (win32-dev, linux32-dev, linux64-dev, macos-64-dev); in Netbeans you would right-click on the project, and select Git -> Branch/Tag -> switch branch. Once you've checked out the right branch, again right-click on the project and select Properties -> Libraries (or if there is a Libraries folder in the project you can right click there and select Properties, it should open Project Properties -> Libraries directly). Make sure that the OpenOffice SDK library is present under Classpath, if not click on the + to the right of Classpath and select Add library… , you should find OpenOffice 4.1.7 (or OpenOffice 4.1.8 on Linux) there. Other libraries are needed but it shouldn't be necessary to download them, they should be packaged into the libraries folder in the repository already:

Each OS-build branch of the project should have it's own versions of the following jar files, useful for the JCEF component:

  1. Windows-32 development branch:

    • gluegen-rt.jar
    • gluegen-rt-natives-windows-i586.jar
    • jcef.jar
    • jcef-tests.jar
    • jogl-all.jar
    • jogl-all-natives-windows-i586.jar
  2. MacOS-64 development branch:

    • gluegen-rt.jar
    • gluegen-rt-natives-macosx-universal.jar
    • jcef.jar
    • jcef-tests.jar
    • jogl-all.jar
    • jogl-all-natives-macosx-universal.jar
  3. Linux-32 development branch

    • gluegen-rt.jar
    • gluegen-rt-natives-linux-i586.jar
    • jcef.jar
    • jcef-tests.jar
    • jogl-all.jar
    • jogl-all-natives-linux-i586.jar
  4. Linux-64 development branch

    • gluegen-rt.jar
    • gluegen-rt-natives-linux-amd64.jar
    • jcef.jar
    • jcef-tests.jar
    • jogl-all.jar
    • jogl-all-natives-linux-amd64.jar

    It shouldn't be necessary to download any of the jars, seeing they are already in the "libraries" folder, however they probably do need to be added to the classpath in the IDE (same process as above: right click on the project and select Properties -> Libraries then click on the + to the right of Classpath and select Add jars, navigate to the project folder and into the libraries folder and select all of the libraries.) They should now show up under "libraries" in the project structure.

  5. Make sure the right JDK is used for the build process: right-click on the project and select properties -> libraries, make sure that Java Platform is pointing at:

    • JDK 1.8 x86 if building for Windows
    • JDK 11 x64 if building for Linux x64
    • for Linux x86 we need more information
    • for MacOS we need more information
  6. If building for Linux x64, a number of system dependencies will need to be met especially if the Chrome browser is not already installed on the system. Also some environment variables need to be set. However this should be taken care of during installation of the plugin.

  7. The Development environment should now be complete. Right clicking on the project, there should be some context menu items from the AOO extension for Netbeans (probably near the bottom of the list):

    • Debug the extension in Apache Open Office
    • Install the extension in Apache Open Office
    • Create the OXT file
    • Publish the extension on the Apache OpenOffice website

    For development purposes, the most useful context menu item will be Debug the extension in Apache Open Office. This will temporarily install the current build of the plugin in Open Office (it will replace any existing installation of the plugin, at least temporarily). Allow it to do so, accept the license agreement, and then once the installation is complete go ahead and close the extensions window. Open Office should open (or at least the initial suite interface, where you can choose to create a new document). You should now find the new BibleGet menu! And a floating toolbar with the same items as in the top level menu. And any debug information (such as System.out.println calls) will be output to the Netbeans console. If you don't see the Output console in Netbeans, open the Window menu and click the Output menu item, the Output console should become visible. This is very useful for debugging during development.

    N.B. When Debug->Running in Linux x64, the OpenOffice plugin installer window might hang the first time while installing the BibleGet plugin. In the Netbeans Output console the last message would probably be: debugging UNO extension package ... /opt/openoffice4/program/unopkg gui -f /home/yourusername/NetBeansProjects/bibleget-openoffice/dist/BibleGetIO.oxt. Usually if you wait a while, it will eventually install. If you see that more than 5 minutes go by without any success, try closing the window and closing OpenOffice (if it opens) and launch the Debug->Install again...

Development branches

Since the HTMLEditorKit in Java Swing is quite outdated (doesn't allow for CSS3 or HTML5), I found an alternative in the Java Chrome Embedded Framework, which should support all of the latest web technologies, seeing that it brings the Chrome browser to a Swing / AWT application. The first attempt to implement JCEF was started under a JCEF branch, which was pulled into the master and development branches on October 22nd 2020 seeing that development for the JCEF functionalities was successful. Now differentiated development branches are being created in order to test the build process for different platforms.

Steps to take to make sure the development environment is ready for JCEF

So far the development process has been tested in a Windows environment. The final integration should contemplate compatibility with Linux (both x86 and x64) and MacOS (x64) other than for Windows (x86). In each development branch, the necessary JARs for the relative platform are included in the Libraries folder; make sure they are also referenced in the project's classpath (in Netbeans, right-click on Libraries -> Properties and make sure the JARs are in the Classpath).

It is not however sufficient to include the JARs in the classpath, the native libraries also need to be included. I believe I have succeeded in setting the java.library.path at runtime from within the code, at least for Java 1.8 on Windows, so the process should be automated at runtime now, it shouldn't be necessary to add the folder to your system path.

In any case the necessary builds that are obtained automatically by the initialization code can be obtained from here:

The JAR files included in the Libraries folder for each development branch come from exactly this release of jcefbuild.

During initialization, the plugin installs two things to the following user paths:

  • on Windows: C:/Users/yourusername/AppData/Roaming/BibleGetOpenOfficePlugin/
  • on Linux: /home/yourusername/.BibleGetOpenOfficePlugin/
  • on MacOS: /Users/yourusername/Library/BibleGetOpenOfficePlugin/
  1. a Derby database in the BIBLEGET folder, which persists user preferences
  2. the JCEF native libraries in the JCEF folder (on MacOS it should be the jcef_app.app folder). These are downloaded by the plugin from the same Github release URLs as shown above, unzipped in memory and saved to the temp folder, where the necessary files are then copied to the User folder as indicated above. The download only occurs if the necessary files are not present in either the User folder or the Temp folder; if they are present in the Temp folder but not the user folder, then they are simply copied from the Temp folder to the User folder. If not present in either folder then they are downloaded from the Github release URLs. For now the URLs are hardcoded, in future development the Github API will be used in the plugin to detect the URLs based on the desired release.

Feedback is needed if the build process is successful on platforms other than Windows. If you have successfully built the plugin and run it in OpenOffice without getting any exceptions and everything seems to be working nicely, please sign here under the build:

  • Windows-32-dev

    -- John D'Orazio completed build and Debug->Install in Apache OpenOffice 4.1.7 successfully on November 2nd 2020

  • Linux-32-dev

  • Linux-64-dev

    -- John D'Orazio successfully completed build and Debug->Install in Apache OpenOffice 4.1.7 on November 8th 2020, in Ubuntu 20.04 (WSL2 on Windows 10) (except for some gpu errors which may be due to the WSL2 Ubuntu environment), however the process involved installation of system packages and setting of environment variables, plus overwriting nss libraries in the OpenOffice folder with more recent versions (this should not be required from OpenOffice 4.1.8 onwards, so the plugin should probably be only built against OpenOffice 4.1.8 so we don't have to fiddle around with the OpenOffice installation).

    -- John D'Orazio successfully completed a semi-automated build and Debug->Install in Apache OpenOffice 4.1.7 on November 14th 2020, in Ubuntu 18.04 (WSL2 on Windows 10). The installation of system packages and setting of environment variables was done at runtime, through an experimental setup interface.

    -- John D'Orazio successfully completed a build with Debug->Install in Apache OpenOffice 4.1.8 on December 17th 2020 in Ubuntu 20.04 (true instance, not WSL2). The automated setup interface needed a couple of tune-ups, after which the build completed successfully

  • MacOS-64-dev