Thanks, @Redhorse! I started yesterday to draft an answer. Yours helps me now! I agree, this is not a XWiki issue, but it affects the XWiki functioning. I think it is worth to describe and document it here at some extent.
java -version
show the Java
used by the command line, not the Java
used by Tomcat at startup. Not sure about how this is set up.
/etc/default/tomcat9
, in my server, reads:
# The home directory of the Java development kit (JDK). You need at least
# JDK version 8. If JAVA_HOME is not set, some common directories for
# OpenJDK and the Oracle JDK are tried.
#JAVA_HOME=/usr/lib/jvm/java-8-openjdk
Thus, the part of your answer about picking Java version by alphabetic listing seems to make sense: if we set JAVA_HOME
there, we are in the safe side! But also, if you list /usr/lib/jvm
, you will find:
rjr@IGFAE-MU-07-MacPro:/usr/lib/jvm$ ls -l
total 20
lrwxrwxrwx 1 root root 25 Mar 24 2022 default-java -> java-1.11.0-openjdk-amd64
lrwxrwxrwx 1 root root 21 Aug 25 00:33 java-1.11.0-openjdk-amd64 -> java-11-openjdk-amd64
lrwxrwxrwx 1 root root 21 Oct 19 09:43 java-1.17.0-openjdk-amd64 -> java-17-openjdk-amd64
lrwxrwxrwx 1 root root 21 Jul 22 2022 java-1.18.0-openjdk-amd64 -> java-18-openjdk-amd64`Preformatted text`
drwxr-xr-x 9 root root 4096 Nov 30 06:31 java-11-openjdk-amd64
drwxr-xr-x 7 root root 4096 Jan 31 08:16 java-17-openjdk-amd64
drwxr-xr-x 9 root root 4096 Oct 2 14:51 java-18-openjdk-amd64
drwxr-xr-x 2 root root 4096 Nov 30 06:31 openjdk-11
drwxr-xr-x 2 root root 4096 Oct 2 14:51 openjdk-18
rjr@IGFAE-MU-07-MacPro:/usr/lib/jvm$
There is a symlink there in, default-java
, pointing to Java 11
!
If I remove it, create a new one pointing to Java 18
, comment out JAVA_HOME in /etc/default/tomcat9
, and restart Tomcat 9, XWiki starts up.
This defaul-java
symlink should be managed by update-alternatives
. This doesn’t happen here. It seems to me that I have, perhaps we have, a messy Java installation. I remember, but not completely sure, I installed manually Java 18
. No idea about Java 11
and Java 17
. As update-alternatives
is an APK thing, perhaps I broke something. Removing and recreating the defaul-java
symlink, works.
I understand now more about how Java works in Ubuntu. I hope to find this thread when XWiki removes support for Java 17 in 2026!