Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Adding multi-jar and Jigsaw support to JPedal and JDeli

1 min read

jigsaw

One of the really exciting features added into Java 9 was the ability to have a multi-jar release. This means if you want to use a later version of Java, then you can still have a jar for Java 8 that will just contain extra or different versions of classes for the later version. This feature was introduced in Java 9 in JEP-238. This makes it easier to try to support the most users (realistically Java 8) while allowing use of more modern features if a more modern Java version is available.

How did we add multi-jar support?

Adding multi-jar support needs a little bit of work in Java. I have found 2 approaches to doing it in Maven. Either you can recompile the Java11 code using AntRun or you can have 2 Maven modules. Because we have a separate build module in JPedal and JDeli for the shade plugin, we used the second approach. There is also a really good article from Trisha Gee on creating multi-jars in IDEA.

At the moment, we are using this to add ONE additional file, module-info.java. This is another Java 9 feature (project Jigsaw) which allows users to make use of modularisation in their code. This allows us to lock the code down to the official API for JPedal/JDeli if you are using Java 9 or later. The module names are com.idrsolutions.jpedal and com.idrsolutions.jdeli for the module settings If you are using Java 8, nothing should change…

What does this mean going forward?

This means, while we support all Java releases 8 and above. We will be able to offer optimisations for the latest LTS and still providing complete support for an older version. When we change the LTS, we will review this base release. This is likely to stay as Java 8 in the foreseeable future. Any changes will be announced well in advance on our blog, as we did with the move to Java 8, and we will ask for customer feedback first.  We will also be looking into any areas of the code where we can gain substantial performance or memory advantages from having an optimised Java 11 version of the code for Java 11 users.

Currently, we regard the inclusion of module-info as experimental, so we welcome any feedback, ideas, or Java 11 specific enhancements. What are your thoughts?



Are you a Java Developer working with Image files?

Why do developers choose JDeli over free alternatives?

  1. Works with newer image formats such as AVIF, HEIC, JPEG XL, WEBP
  2. Better support than alternatives for JPEG, PNG, TIFF.
  3. Prevent JVM crashes caused by native code in other image libraries
  4. Better performance than other popular Java image libraries
Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.