Which java/openjdk version to use for my jar extension?

I’m writing my own extension in Java. My pom.xml looks like this:

<parent>
   <groupId>org.xwiki.commons</groupId>
   <artifactId>xwiki-commons-pom</artifactId>
   <version>11.10.3</version>
</parent>
<!-- more stuff removed for brevity -->

I’m not a Java expert, and I looked at the Java Support Strategy for XWiki. So my confusion is: how could xwiki-commons and xwiki-* other modules support both Java 8 and Java 11 ? I mean xwiki-commons is built with either Java 8, or Java 11, but not both? And indeed, xwiki-commons/**/pom.xml seems to mention Java 8 only:

<!-- Java -->
<java.version>1.8</java.version>

(I assume Java 1.8 means the same thing as Java 8)

Does that mean xwiki-commons is built with Java 8 only? If so, does that mean I’m forced to use Java 8 to build my extension? If so, why does Java Support Strategy mention Java 11 as well?

Java is retro compatible. XWiki is built with Java 8 to be sure it run in Java 8 or more.

In general you should build you extension with the same version of Java used by the minimum version of XWiki you support. If you used the wrong one you will get an error when releasing anyway (there is an enforcer configured in the parent pom) so you should be safe.

1 Like

@tmortagne

Java is retro compatible. XWiki is built with Java 8 to be sure it run in Java 8 or more .

That means I can use Java 11 ? and it’ll still work with xwiki-commons even if it’s built with Java 8.

In general you should build you extension with the same version of Java used by the minimum version of XWiki you support. If you used the wrong one you will get an error when releasing anyway (there is an enforcer configured in the parent pom) so you should be safe.

The minimum version of XWiki is Java 8? Now that sounds confusing. Looks like I’m missing something. :thinking:

We recommend using Java 11 with XWiki.

You are mixing XWiki and Java here. In your example you seems to support XWiki 11.10.3 as minimum XWiki version so you should build with Java 8 since that’s what this version of XWiki supports (i.e. a user of your extension might be running XWiki in Java 8 since it’s supported).

1 Like

I see.

In that case, Java 11 shouldn’t be used anywhere (by any extension), because it is not a minimum version of any XWiki (as per Java Support Strategy which says that XWiki >= 11 supports Java 8)?

Ideally yes. Now you might create an extension that really require Java 11 for some reason or only really make sense in a Java 11 environment (in which case you will disabled the Java version check in the pom) but that’s the only valid reason to build something with Java 11 IMO (or you just don’t care and want to use new Java 11 stuff but that’s not so nice for other XWiki users :slight_smile: ).

1 Like

Honestly, now that confuses me more. I think you’re mixing two different kinds of problems, i.e mixing a technology problem with the adoption by XWiki users problem. Since I dont have any XWiki users, as I’m only playing around with XWiki by writing an extension, I dont have the adoption problem.

Also, it also confuses me as to what does the support of Java 11 actually mean as mentioned on the website, if extension writers should use Java 8 ? I ran the docker image xwiki:latest locally, and it seems to be using Java 11. I just logged-in to the container and did printenv which shows the following among other things:

JAVA_HOME=/opt/java/openjdk
JAVA_VERSION=jdk-11.0.4+11
XWIKI_VERSION=11.8

Now I’m completely confused. :confused:

It means “runs on”.

1 Like

Just added a bullet point on https://dev.xwiki.org/xwiki/bin/view/Community/SupportStrategy/JavaSupportStrategy/

1 Like

We are discussing extensions here and yes when someone mention working on an extension I assume that a release is planned at some point so I’m giving you the recommendation regarding the extensions and what they mean. The answer to the technology problem was my first message: yes when you build with Java 8 it works in Java 11.

1 Like