Simple jar Snap with bundled jre

Hello,
i am very sorry if this question is dublicated, if it is, than inform me about it.

(First of: I am very new to snaps)
I have a already compiled jar, from which i want to create a snap which bundles the jre.

I rode the basic docs and ended with this configuration:

name: SkIde
version: '0.0.5' 
summary: IDE for Skript
description: to lazy to do than now

confinement: devmode

apps:
  SkIde:
  command: java -jar $SNAP/SkIde.jar

parts:
  skide:
    source: /home/liz3/tc_out/
    plugin: jdk

(The absolute Jar file path is /home/liz3/tc_out/SkIde.jar)
My problem is now that when i install the generated snap and try to run it, it says: java not found.
Now my question is, how do i need to invoke java, that it will use the bundled jre?
Can someone provide me a example configuration.

Note: i cannot use the gradle or maven plugins because i need to build the jar before generating the snap.

Kind Regards
Yann “Liz3” HN

here is an example java snap i wrote long ago:

Instead of using the jdk plugin, which brings in a full jdk instead of just the jre I would do something like

name: SkIde
version: '0.0.5' 
summary: IDE for Skript
description: to lazy to do that now

confinement: devmode

apps:
  SkIde:
  command: <relative-path-to dir-in-prime-to-java>/java -jar $SNAP/SkIde.jar
  adapter: none
  environment:
    JAVA_HOME: $SNAP/<relative-path-to dir-in-prime-to-java-home>

parts:
  skide:
    source: /home/liz3/tc_out/
    plugin: dump
  jre:
    source: <path-to-oracle-jre-tar>
    plugin: dump

Or whatever brand of JRE you can or want to use.
If you have GUI requirements, you will need to do something similar to what @ogra did.

1 Like

Hi @ogra, I’m very new to snapcraft. I’ve read your code again and again and I could not succeed to make the java runtime available in the snap.
I really feel stuck now

The test gives me the well known :

java: not found

You can find the Travis build output it it can help : https://travis-ci.org/adriens/schemacrawler-snapcraft/builds/449298036

I guess I’m not that far from maing it run ?

Thank you in advance for your help.

Kind Regards,
Adrien

try an apps: entry like:

apps:
  schemacrawler:
    command: schemacrawler-15.01.04-distribution/_schemacrawler/schemacrawler.sh
    environment: 
      JAVA_HOME: $SNAP/usr/lib/jvm/java-1.8.0-openjdk-$SNAP_ARCH
      PATH: $JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
1 Like

@ogra !!!..it perfectly did the job !!! Thanks a lot for you silver bullet :muscle: :+1: :fireworks: