How can I snap a jar?

I have a jar file that I build separately that I want to create a snap of.

    source: builds/libs/
    plugin: dump

    command: java -jar $SNAP/myjar.jar
    daemon: simple
    restart-condition: always

When I try to turn this into a snap I get the error:

The specified command ‘java’ defined in the app ‘java-service’ does not exist or is not executable

I figured out that I have to use the jdk plugin. Didn’t realize that it was a thing since it wasn’t included on the list of plugins for java.


Do you use Maven as building tool for your JAR file. If so, you can use the
maven plugin for the part in the yaml file which builds your application. I
have a Java application packaged as a snap in the store and succesfully
working since the last year. You can check the yaml file and the rest of
the files here:

I hope it helps you!