javaintellij-ideajava-8twelvemonkeys

TwelveMonkeys ImageIO is not working after build in to jar with OpenJDK8


I'm currently adding additional functionality to my program by using this library: https://haraldk.github.io/TwelveMonkeys/ TwelveMonkeys ImageIO.

It works great in Editor - Intellij IDEA 2020.1.1 but when I build the project into the jar it's not working.

Error:

Exception in thread "main" javax.imageio.IIOException: Unsupported Image Type
        at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1036)
        at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1007)
        at javax.imageio.ImageIO.read(ImageIO.java:1462)
        at javax.imageio.ImageIO.read(ImageIO.java:1309)

This error is telling that internal java imageio used, not from TwelveMonkeys. I have tried to set priority in modules but that also didn't helped:

Modules Artifacts

Java version:

java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (Zulu 8.46.0.19-CA-win64) (build 1.8.0_252-b14)

Solution

  • @haraldK Thanks for answer. It took me several days to actually figure out but now it's working. A little bit of explanation of what I have done:

    1. Transfer to Maven project
    2. Add to pom.xml all dependencies
    3. Add maven-shade-plugin
    4. Used two transformers: ServicesResourceTransformer and ManifestResourceTransformer