How to fix Java Environment on Ubuntu 22.04 for Zotero?

I have installed the Zotero from APT, placing the folder on /opt. I have problems with the Java environment (JRE). On this post, it is said that one needs to run sudo apt install default-jre and sudo apt install libreoffice-java-common. But I already have them:

$ sudo apt install default-jre
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
default-jre is already the newest version (2:1.11-72build2).
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
$ sudo apt -y install libreoffice-java-common
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libreoffice-java-common is already the newest version (4:7.6.4-0ubuntu0.22.04.1~lo1).
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
$ java --version
openjdk 11.0.21 2023-10-17
OpenJDK Runtime Environment (build 11.0.21+9-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.21+9-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)
$ ls /usr/lib/jvm/
java-11-openjdk-amd64

Still I am getting Java errors when I start LibreOffice Writer:

Screenshot from 2024-02-15 10-17-30

There is not Java environment at all in Tools>advanced:

It is not the first time that I set the JRE and then it is lost after a few months.

How can I fix the JRE for LibreOffice?

Thank you

for reference :

Yes, similar. But this is an additional error, the step after. The bottom line is: still, there is no JRE.

I even tried to reinstall Java (actually on top of the one I have) with sudo apt install openjdk-17-jdk -y. Now I have Java 17 instead of 11:

$ java -version
openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Ubuntu-122.04)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Ubuntu-122.04, mixed mode, sharing)

But nothing has changed on the L.O. side.

Your LibreOffice installation is a container installation, right? Ask your distributor how to configure that f***ing container to access system libraries such as JRE.
Better install LibreOffice directly into your system: Java Runtime in 24.2 - #4 by Villeroy

Thank you for the straight answer. I understood the distributor of LibreOffice was LibreOffice… Ubuntu did not give any answer on it. Anyway, since LO does not allow access to /usr/lib/jvm how can I link JRE to LO? I tried with symbolic links to /usr/lib/jvm/java-11-openjdk-amd64 and /usr/lib/jvm/java-11-openjdk-amd64/bin/java in an accessible folder, but LO does not recognize them.

Yes, your Java is installed properly. However, LibreOffice runs in a container. It does not know much about your system beyond your home directory. This is configurable, and the Ubuntu folks fail to do so. Container apps are convenient for developers. For users they are a pain …

1 Like