Creating a Snap which implements Java JRE in the ctrlX Core Devices (arm64)

Hi Community, 

i am trying to create snap which then implements Openjdk-jre-arm64. Java JRE should be a part of the snap, which means it should be defined in snapcraft.yaml file.

If anybody already created a snap which runs a Java Runtime Env on the ctrlX Device, i would appreciate help on this topic. 

This are my approaches for this task:

1.)  snapcraft.yaml

 

architectures:
  - build-on: amd64
    run-on: arm64

part:
   mypart:
        ...
        stage-packages:
      - on amd64 to arm64: [openjdk-11-jre] #i tried also [openjdk-11] 

 

i assume this way snapcraft.yaml file takes the snap available in the snap-store: https://snapcraft.io/openjdk

Test results: Doesent create a java arm64 package but a java amd64 package. 

2.) snapcraft.yaml

architectures:
  - build-on: amd64
    run-on: arm64

part:
   mypart:
     jre:
        plugin: dump
        source: https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.11%2B9/OpenJDK11U-jre_aarch64_linux_hotspot_11.0.11_9.tar.gz
        build-packages:
            - tar
            - gzip

  

Test results: it installs the right arm64 package into the ctrlX Core device. Though not working. 

3.) implement from repository

#package-repositories:
# - type: apt
# architectures: [arm64]
# formats: [deb, deb-src]
# components: [main]
# suites: [stable]
# key-id: not found
# url: http://ftp.de.debian.org/debian/pool/main/o/openjdk-11/openjdk-11-jre_11.0.11+9-1_arm64.deb
#http://ftp.de.debian.org/debian/pool/main/o/openjdk-11/openjdk-11-jre_11.0.11+9-1_arm64.deb

There is also a way to choose another repository or own hosted repository besides http://security.ubuntu.com/ubuntu/, which is the standard repo when snapcraft installs packages during building process.

Test results: no test results since i wasnt able to find the key-id (gpg) of the package.

NOTE:

I directed at any of these approaches the java jre into the $SNAP/usr/lib/jvm path. Which is the supposed place for a java runtime enviroment.

 

 

 

Best reply by DiluMarku

Hi blendajazi,

I don't know if you still need help but this implementation works for me:

...

architectures:
  - build-on: amd64
    run-on: arm64

apps:
  java-server:
    command: bin/main
    ...
    environment:
      JAVA_HOME: $SNAP/usr/lib/jvm/java-11-openjdk-arm64
      PATH: $JAVA_HOME/jre/bin:$PATH

parts:
  preparations:
    plugin: nil
    source: .
    ...
    build-packages:
    - openjdk-11-jdk
    stage-packages:
      - openjdk-11-jre-headless:arm64

...

 

 

View original
2 replies