How can I snap a jar?

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

parts:
  webserver:
    source: builds/libs/
    plugin: dump

apps:
  java-service:
    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.

Hi!

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:

https://bitbucket.org/eloy_garcia_pca/wallpaperdownloader/src/e616354e6a14d1e79936648907e4056f3df477bb/snap/?at=master

I hope it helps you!

Eloy