Skip to the content.

← Back to Home

Snap Packaging for SmallTextPad

This guide covers building Snap packages for SmallTextPad, a lightweight Java text editor with encryption and multi-language support.

Files

Prerequisites

System Requirements

Installing Build Dependencies

Ubuntu/Debian:

sudo apt update
sudo apt install snapcraft openjdk-21-jdk

Fedora/RHEL:

sudo dnf install snapd openjdk-21-jdk
sudo ln -s /var/lib/snapd/snap /snap  # Enable classic snap support
sudo systemctl enable --now snapd.socket
# Install snapcraft
sudo snap install snapcraft --classic

Other Distributions:

# Install snapd first (varies by distribution)
# Then install snapcraft
sudo snap install snapcraft --classic

Building the Snap Package

Standard Build:

cd packaging
./build-snap.sh

Build on Systems Without LXD (e.g., Raspberry Pi):

snapcraft pack --destructive-mode

The script will:

  1. Clean previous build artifacts
  2. Rebuild the source list
  3. Compile Java sources
  4. Create the JAR file
  5. Package everything as a Snap with snapcraft pack

Package Details

Package Information

Snap Configuration

The snap includes:

Permissions (Plugs)

The snap requests the following permissions:

Build Output

After successful build:

Installing the Snap

Install Locally (Development):

sudo snap install --dangerous classes/artifacts/smalltextpad_1.5.0_*.snap

The --dangerous flag is required for local snaps that aren’t signed by the Snap Store.

Install from Snap Store (When Published):

sudo snap install smalltextpad

Using the Application

Once installed, you can:

  1. Launch from application menu: Look for “SmallTextPad” in your applications
  2. Launch from command line: smalltextpad
  3. Open files: smalltextpad /path/to/file.txt

Snap-Specific Features

Confinement

The snap runs in strict confinement mode, which means:

Auto-Updates

When installed from the Snap Store, the application will:

Snap Commands

Check snap info:

snap info smalltextpad

View snap connections:

snap connections smalltextpad

Remove the snap:

sudo snap remove smalltextpad

Connect additional interfaces (if needed):

sudo snap connect smalltextpad:removable-media

Publishing to Snap Store

To publish SmallTextPad to the Snap Store:

  1. Register the snap name:
    snapcraft register smalltextpad
    
  2. Build and upload:
    snapcraft
    snapcraft upload --release=stable smalltextpad_1.5.0_amd64.snap
    
  3. Automated publishing:
    • The project can use GitHub Actions or other CI/CD
    • Upload to Snap Store happens automatically on release

Multi-Architecture Support

Building for Different Architectures:

For amd64 (x86_64):

architectures:
  - build-on: amd64

For arm64 (ARM64/aarch64):

architectures:
  - build-on: arm64

For multiple architectures:

architectures:
  - build-on: amd64
  - build-on: arm64
  - build-on: armhf

Edit snap/snapcraft.yaml to modify the architecture settings.

Troubleshooting

Snapcraft Not Found:

Install snapcraft:

sudo snap install snapcraft --classic

LXD/Multipass Issues:

Use destructive mode (builds directly on host):

snapcraft pack --destructive-mode --output=classes/artifacts/smalltextpad_1.5.0_amd64.snap

Permission Denied Errors:

Ensure the build script is executable:

chmod +x packaging/build-snap.sh

JAR Not Found:

The snap build expects a pre-built JAR. Build it first:

./packaging/build-jar.sh

Desktop File Not Showing:

Check that the desktop file exists:

cat snap/gui/smalltextpad.desktop

Application Won’t Start:

Check snap logs:

snap logs smalltextpad -f

Snap Package Structure

Inside the snap:

/snap/smalltextpad/current/
├── SmallTextPad.jar          # Application JAR
├── res/                       # Image resources
├── dic/                       # Dictionary files
├── bin/
│   └── smalltextpad          # Wrapper script
└── usr/
    ├── lib/jvm/              # Bundled Java runtime
    └── share/
        ├── applications/      # Desktop file
        └── pixmaps/          # Application icon

Development Notes

Testing

Before publishing, test the snap thoroughly:

# Install locally
sudo snap install --dangerous classes/artifacts/smalltextpad_*.snap

# Test launching
smalltextpad

# Test with file
smalltextpad test.txt

# Test file associations
xdg-mime query default text/plain

# Check permissions
snap connections smalltextpad

# View logs
snap logs smalltextpad

See Also