Installing the code for «Java LibreOffice Programming»
I’ve only tested my code on Windows machines, so this page will limit itself to that platform.
1. Downloading LibreOffice and Other libraries
- Check if your machine is 64-bit or 32-bit (e.g. by calling systeminfo from the command line, and looking at the «System Type» entry). If you have a 64-bit machine then you’ll have to decide whether to download the 64-bit or 32-bit versions of the JDK and LibreOffice, but make sure the pair you choose have the same «bitness». If you’ve got a 32-bit machine, then you’ll have to get the 32-bit pair of JDK and LibreOffice.
- Download a Java SE Development Kit (JDK). The Java site uses «x86» as another name for 32-bit. Install it in its default position on your machine. Add the full directory path holding the Java compiler and runtime executables to Window’s PATH environment variable. The directory path typically ends with Java\jdk1.8.0_XXX\bin.
- Download LibreOffice. Install it in its default position on your machine. Add the full directory path containing the LibreOffice executable (soffice.exe) to Window’s PATH environment variable. The directory path typically ends with LibreOffice 5/program.
By the way, there are two versions of LibreOffice to choose from, called ‘still’ and ‘fresh’. I usually download ‘fresh’, but the ‘still’ version is available here. By the way, if you want to download LibreOffice version 4 instead of the new version 5, that’s fine as well. - Download the SDK from the same webpage as LibreOffice (for Windows, it’s an MSI file). There’s no need to get the source code. The installed SDK will appear as an sdk subdirectory in the LibreOffice directory. Optionally download the built in Help as well, but LibreOffice will default to using the online version if Help isn’t installed.
- Download JNA. There are two files to download (jna.jar and jna-platform.jar) which are listed in the Download section some way down the JNA webpage. Install these files in the directory D:\jna on your machine. This location is used by my compile and run batch files.
2. Installing my Utility Classes
The utility classes are in a folder Utils, which can be downloaded as a zipped file. It should be unzipped and placed in a new subdirectory for your LibreOffice programs. This directory can be called anything; mine is called LibreOffice Tests.
3. Installing my Examples
Links going to the zipped examples can be found in the chapter sections on the main page of this site
Поддержка платформы Java
В LibreOffice поддерживается платформа Java, используемая для выполнения приложений и компонентов на основе архитектуры JavaBeans.
Для поддержки Java в LibreOffice следует установить виртуальную машину Java 2. После установки LibreOffice автоматически появится возможность установки этих файлов, если они ещё не установлены. При необходимости можно установить эти файлы прямо сейчас.
Чтобы запускать приложения Java, необходимо включить поддержку платформы Java в LibreOffice.
Активируйте платформу Java путём выбора команды LibreOffice — Параметры Сервис — Параметры — LibreOffice — Расширенные возможности .
Перед использованием драйвера JDBC необходимо добавить путь его класса. Выберите LibreOffice — Параметры Сервис — Параметры — LibreOffice — Расширенные возможности и нажмите кнопку «Путь класса». Затем перезапустите LibreOffice.
Изменения на вкладке LibreOffice — Параметры Сервис — Параметры — LibreOffice — Расширенные возможности будут использованы даже в том случае, если виртуальная машина Java (JVM) уже запущена. После изменения переменной ClassPath необходимо перезапустить LibreOffice. Это же справедливо для изменений в разделе LibreOffice — Параметры Сервис — Параметры — Интернет — Прокси . Перезапуск не требуется только для полей «Прокси HTTP», «Прокси FTP» и их портов. Они будут применены при нажатии кнопки ОК .
Libreoffice does not detect Java on fresh install of 12.10: how to make it work?

There is a bug reported about this but the workaround suggested does not work for me (install libreoffice-base) and is additionally tagged as «won’t Fix»: https://bugs.launchpad.net/ubuntu/+source/libreoffice/+bug/926594
I tried deleting the file mentioned in the error message and re-installing both LibreOffice and openjdk-6 but to no avail. I suppose I could manually add a runtime environment from the LibreOffice Menu Options > Libreoffice > Java but I don’t know which directory to choose.
Frequently asked questions — General
How to install Java (JRE/JDK) so that LibreOffice could use it?

Using Windows
x86 or x64 architecture?
Do not mistake ‘x64’ and ‘x86’ architectures: when using Windows, you need to make sure that the architecture of installed LibreOffice matches the architecture of installed JRE.
- If your Windows is 64-bit, LibreOffice Download page by default offers you a 64-bit LibreOffice installer. It is designated as Windows (64-bit) .
- If you have 32-bit operating system, you will be offered a 32-bit installer ( Windows (32-bit) ).
You may check the architecture of installed LibreOffice in menu Help ▸ About LibreOffice , where the version string looks like «Version: 6.4.5.2 (x64)» for 64-bit version, and «Version: 6.4.5.2 (x86)» for 32-bit version.
LibreOffice can only use JRE with matching architecture: i.e., 64-bit LibreOffice can only use 64-bit JRE, and 32-bit LibreOffice can only use 32-bit JRE.
When you have installed a 64-bit LibreOffice, and 32-bit JRE, LibreOffice would not be able to find and use the JRE, no matter how hard you would try it. Take care that you download from the Java home page (www.java.com) the right architecture. In this case, LibreOffice (of reasonably fresh version) would try to be helpful in its «JRE Required» error message, telling you that it needs specific architecture (e.g., 64-bit) of JRE.
Download links
To find other available downloads, including 64-bit JRE, you need to ignore the Big green «Download Java» button, and find a small See all Java 8 Downloads for Desktop users link below.
Then, in the manual download page, you have to choose the right version. (If you are in doubt, you can install both.)
Package names
Java installer packages typically have this naming scheme:
- jre-8u201-windows-i586-iftw.exe or JavaSetup8u261.exe — 32-bit web-installer;
- jre-8u201-windows-i586.exe — 32-bit standalone installer;
- jre-8u201-windows-x64.exe — 64-bit standalone installer.
Thus, be aware that ‘standard’ build, with a naming scheme like JavaSetup8u341.exe will NOT work with LibreOffice. This is why you have to use the manual download link.
How to control what JRE version in installed
JREs which are installed into C:\Program Files (x86) (as opposed to C:\Program Files) are 32-bit (unless you manually modified install path during installation), so you may use this information to tell if your JRE is 32-bit or 64-bit.
Launching Java Control Panel («Configure Java» available in Windows Start menu), and clicking «View» button on «Java» tab, opens Java Runtime Environment Settings window with Architecture column allowing to see if installed instances are 32-bit (x86) or 64-bit (x86_64).

It is possible to install both 32-bit and 64-bit Java simultaneously on the system; and they don’t conflict with each other — so if in doubt, just install both.
Using macOS
On macOS 10.10 and newer, please note that you need to install JDK, not JRE. You may find download links choosing JDK version on this page. Note that Apple M1 is an Arm 64 architecture. On macOS 10.09, neither JRE, nor JDK are found. LibreOffice releases available from Apple App Store don’t include Java support at all, because apps distributed in the App Store are not allowed to depend on optional functionality like Java.