because it does not run as a snap then and uses JAVA_HOME from your current shell session (read: it runs on the host as if you just had unpacked it to /opt, not in the snap env under confinement)
Haha! I suspected that! It all seemed too easy.
check if your path in the wrapper is correct: find /snap/myapp/current/ -name ‘java’
chris@desktop:~$ find /snap/myapp/current/ -name '*java*'
/snap/myapp/current/etc/java-8-openjdk
/snap/myapp/current/etc/java-8-openjdk/security/java.policy
/snap/myapp/current/etc/java-8-openjdk/security/java.security
/snap/myapp/current/etc/ssl/certs/java
find: ‘/snap/myapp/current/etc/ssl/private’: Permission denied
/snap/myapp/current/lib/java-http-proxy.jar
etc....
> snap run --shell myapp
env produces (edited)
chris@desktop:/home/chris$ env
SNAP_USER_COMMON=/home/chris/snap/myapp/common
USER=chris
SNAP_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void
SNAP_COMMON=/var/snap/myapp/common
SNAP_INSTANCE_NAME=myapp
SNAP_USER_DATA=/home/chris/snap/myapp/x1
SNAP_DATA=/var/snap/myapp/x1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
HOME=/home/chris/snap/myapp/x1
SNAP_NAME=myapp
SNAP=/snap/myapp/x1
...
chris@desktop:/home/chris$
Which looks OK to me, so I don’t understand what is wrong.
This is what I have run: #to install utilities sudo apt install snapcraft build-essential sudo snap install lxd sudo lxd init # accept all the default settings sudo adduser chris lxd #logout and login again
#to create snap sudo cd /home/chris/myapp sudo snapcraft clean myapp sudo snapcraft cleanbuild sudo snap install --devmode myapp_0.0.0_amd64.snap
#to run myapp
I also have a Python app which I have Snapped and which starts OK (it errors with "No module named ‘PIL’ ", but that’s for another day :). So what is the difference?
App under discussion
version: '3.46.1'
summary: An electronic circuit layout designer for stripboards.
description: |
Electronic circuit layout designer for stripboards.
DIY Layout Creator (myapp for short) is a drawing tool developed with help of a
large online community of DIY electronics enthusiasts. It incorporates many
ideas that came from people using older versions of the application. The goal
is to provide a simple interface and enough power to let the user draw
schematics, board/chassis layouts and wiring diagrams quickly and
without a steep learning curve.
grade: devel # Start 'devel'. must be 'stable' to release into candidate/stable channels
confinement: devmode # Start 'devmode'. use 'strict' once you have the right plugs and slots
icon: splash.png #added by me
apps:
myapp:
# environment: #added after poster
# JAVA_HOME: $SNAP/usr/lib/jvm/java-1.8.0-openjdk-amd64 #added after poster
# PATH: $JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH #added after poster
#command: desktop-launch $SNAP/myapp-3.46.1/myapp.sh
#command: $SNAP/myapp-3.46.1/myapp.sh
command: bin/myapp/myapp.sh
plugs: [home] #ADDED FOR FILE ACCESS
parts:
myapp:
source: .
plugin: dump
#organize:
# FileChooserDemo.sh: bin/FileChooserDemo.sh #removed, no idea what this does
stage-packages: [openjdk-8-jre, openjdk-8-demo]
Python app
name: pythonapp # you probably want to 'snapcraft register <name>'
version: '1.5.0'
summary: Creates 3D images from photographs taken with an ordinary camera.
description: |
Take a set of photos of a subject and the software will create a 3D image
from each pair of photos in the set, so that you can choose the best.
Vertical and rotational alignment of the left and right images is essential for a
convincing 3D effect, but difficult to achieve with an ordinary camera. The software
corrects any misalignment.
Formats available are anaglyph (red/cyan), side-by-side and crossover.
Several sets of photos can be processed at once, they can be previewed and poor ones can
be deleted.
grade: devel # Start 'devel'. must be 'stable' to release into candidate/stable channels
confinement: devmode # Start 'devmode'. use 'strict' once you have the right plugs and slots
icon: pythonapp_logo.png
apps:
pythonapp:
command: pythonapp.py
parts:
pythonapp:
source: . # the directory in which snapcraft was executed.
plugin: dump
build-packages:
- hugin
- python3
- python3-pil
- libgtk-3-0
- gir1.2-gtk-3.0 #not sure
- python3-gi
- libpython3-all-dev #maybe this is the answer
One has plugs: [home] which I think allows access to the home directory and stage package statements, the other build package statements.