How can you include java in a snap?

I’m trying to create a snap for a java application, and have included java in the snap using:


  • openjdk-8-jdk

I’m specifying ‘all’ architectures as its cross platform.
This works fine when testing locally.
However the snap is rejected when I upload it.
The single error implies it might not like the binaries:

found binaries for architecture ‘all’: lib/x86_64-linux-gnu/, lib/x86_64-linux-gnu/, lib/x86_64-linux-gnu/, lib/x86_64-linux-gnu/, lib/x86_64-linux-gnu/… (many more included)

What should I be doing instead?
For info the full set of files I’m using to generate the snap are here:

Many thanks

A very old java based snap i did is

perhaps that gives you some hints and ideas.

OK, so you are including the jdk but have not made your snap applicable to all architectures.
Maybe I still need to generate architecture specific snaps due to the dependency on the jdk?
Thanks, I’ll give that a go.

1 Like

While your java code may be portable between architectures, the java runtime and the libraries it depends upon are not. So saying your snap supports all architectures is semantically incorrect because the java runtime will be from the architecture of the build host. I recommend using the build service to build all the snap variants and not setting the architectures parameter at all.


Note that this is an artificial restriction i put in myself (since i simply did not have desktop hardware for the other arches back when i created it). As long as the jdk is available in the archive for a certain arch it should just work … (you might need some extra cleverness in the wrapper script though to make sure it gets the library paths right on a per-arch base)

Thanks - that makes sense.