Core22 and Java 17

Hello all. I’ve recently updated one of my apps to use Java 17 to use a few new language features. However, when snapcraft is compiling, I see the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project library: Fatal error compiling: error: release version 17 not supported -> [Help 1]

Is there something I can do in the config file to build java17 into the build process or is this something that needs to be done by the snap devs?

BTW, this all works great outside of the snap ecosystem.

Thank you much,


This does seem to be an error that pops up outside of snaps, as per

Is it possible that you’re building with an older version of Java and running it with a newer runtime version of Java when you’re building outside of snaps?

This part of the stack overflow thread seems particularly relevant: “Searching for this failure message I found this issue on stackoverflow leading me to a bug in lombok. I upgraded to lombok 1.18.22 and that fixed the compilation failure for a successful build.”

Thanks James. I’ll take a look. I certainly could have mis-interpreted the error message to be related to the snap creation when it was something else.

On my build machine I running OpenJDK java 20.0.2+9, so it’s quite a bit newer than either 11 or 17, but your comment has got me thinking that I need to do some more digging.

Thank you

It’s not impossible that Snapcraft is altering the expected environment enough to trigger this when it doesn’t appear elsewhere. But generally, the builds are done in LXD/Multipass and although the paths might be different and there’s the whole Snapcraft.yaml layer around building them, the build environment itself is essentially just a normal Ubuntu distribution and not particularly unique (except for the end result being to create a snap).

While generally all I could advise is to check your dependencies and see if you can update them; more specifically to snaps, if you can build the .jar file externally, you can still use it in snaps by using the dump plugin, which essentially does nothing except copy across pre-built binaries.

Ideally you shouldn’t have to, but this might be a viable way to bypass the build problems and get you to the point you can work on the runtime side of things once you’ve a proper .snap file to work with.