Say Hello To Snug
Chapter 1

Your First Snug Application

This first exercise is for anyone who wants to see Snug working before learning about its configuration options. You can follow it even if you have never built a Java application before.

You may have written a Java application yourself, created one with an AI assistant, or arrived here without an application of your own. We will use the existing Snug JavaFX demonstration application so that everyone starts with the same files. The goal is to create and run a Windows executable first; the explanations of JAR files, runtimes, and packaging will make more sense once you have seen the result.

Your first Snug build

For this first build, you will download Snug and the prebuilt Snug JavaFX demonstration JAR, create a Windows executable using the Snug Quick Build helper, and then run it. You do not need to compile Java code or open a terminal:

  1. Open the latest Snug release page and select the Windows x64 ZIP file from its Assets list:

    https://github.com/synapticloop/snug/releases/latest/ 
  2. Extract the ZIP file to a folder.

The unzipped folder will have the following icons:

Snug Builder icon. Run snug.exe to package a Java application as a Windows executable.
snug.exe

Builds Windows executables from Java applications

Snug Quick Build icon. Drag a Java JAR onto this helper to create a Windows executable.
Snug Quick Build.exe

Lets you build an executable by dragging a JAR file onto it

Snug Preview icon. Use this tool to preview launcher dialogs.
snug_preview.exe

Lets you preview Snug's launcher dialogs.

For this exercise, we will use Snug Quick Build helper. The other tools are explained later in the book.

  1. Download the existing Snug JavaFX demonstration JAR and place it in the extracted Snug folder. A JAR is the file containing the Java application; for this exercise, you do not need to know how it was made. Download the demonstration file from:

    https://github.com/synapticloop/snug/blob/main/assets/snug-javafx-demo-windows.jar

On the GitHub file page, click “Download raw file” to save the JAR.

GitHub file page with the Download raw file control highlighted at the top right. Select it to save the demonstration JAR.
Image: Click the Download raw file icon to download the demonstration JAR.

Your folder should now look like the following:

File Explorer showing Snug Quick Build.exe, snug.exe, snug_preview.exe and snug-javafx-demo-windows.jar together in one folder.
Image: The extracted Snug folder, with the Snug Quick Build helper (Snug Quick Build.exe), the Snug builder (snug.exe), Snug Preview (snug_preview.exe), and the demonstration JAR (snug-javafx-demo-windows.jar).

  1. Drag the JAR file onto Snug Quick Build.exe.
  2. To drag a file, point at the JAR file, hold down the left mouse button, move the pointer over Snug Quick Build.exe, and release the mouse button.

Drag snug-javafx-demo-windows.jar onto Snug Quick Build.exe, following the arrow.

Image: The demonstration JAR being dragged onto Snug Quick Build.exe.

  1. Wait for Snug Quick Build to finish creating the Windows executable. A new file named Example Application Name.exe should appear in the same folder. This is the default filename used by the Snug Quick Build helper. If no EXE appears, open snug.build.log beside the Quick Build helper in Notepad for the builder's diagnostic report.

IMPORTANT: Windows security warnings:

  • When you first run an executable created by Snug, Windows may display a security warning because the application has not been digitally signed. This does not necessarily mean the application is unsafe, but Windows cannot verify its publisher through a code-signing certificate.
  • Only run applications from sources you trust. On computers managed by an organisation, you may need assistance from your IT administrator.
  1. Double-click the file Example Application Name.exe to run it. If a compatible Java runtime is not already available, Snug may ask permission to download one. If so, follow the on-screen instructions to install it. Once a suitable runtime is available, the demonstration application will open.

File Explorer showing the newly created Example Application Name.exe alongside the Snug tools and demonstration JAR.

Image: The new application Example Application Name.exe (outlined in green) generated from the Snug Quick Build helper.

What just happened?

A JAR contains the Java application you started with. The Snug Quick Build helper uses the normal Snug builder to turn it into a Windows executable (.exe).

For now, getting your first executable to run is enough.

Where to go next

You now have a working Windows executable. If you want to give your application its own name, icon, and other settings, continue to Section 2: Building with Snug, where we introduce the normal Snug builder.

~ ~ ~ * ~ ~ ~

If you simply wanted to try Snug, you can stop here.

~ ~ ~ * ~ ~ ~

TABLE OF CONTENTS

Your First Snug Application        2

Where to go next        5

SECTION 1:

ABOUT THIS BOOK        10

About This Book        11

Why Snug?        11

What Snug Offers        12

What Snug Does Not Do        13

SECTION 2:

BUILDING WITH SNUG        16

Building an Application with Snug        17

The Builder and Launcher        17

Before You Begin        17

Quick-Start: Hello Snug JavaFX        17

That's It        22

Packaging Your Own Application        22

SECTION 3:

CUSTOMISING THE SNUG USER EXPERIENCE        25

The Snug Experience        26

What Happens When Someone Double-Clicks?        26

Application Identity        27

Introducing the snug.options File        28

The Application Icon        30

The Splash Screen        31

SECTION 4:

CONFIGURATION OPTIONS        34

How Snug Configuration Works        35

Input and Output        37

Application Identity        40

Changing the Cache Location        40

Application Metadata        41

Java Runtime        43

Application Instance Behaviour        45

Splash Screen Configuration        45

Runtime Download Behaviour        47

Launcher Messages and Localisation        48

Creating Localisation Files        50

Windows Manifest        51

Build and Diagnostic Tools        51

Using a Different Options File        55

A Practical Configuration Workflow        57

Putting It Together        58

SECTION 5:

CUSTOMISING LAUNCHER MESSAGES        60

Your First Message Change and Preview        61

Understanding Launcher Dialogs        62

Customising the Messages        63

Common Localisation Key Suffixes        67

The Runtime Installation Dialogs        67

When Snug Cannot Launch        69

Message Key Reference        69

Replacement Tokens and the Key Reference        75

Keys Without Replacement Tokens        80

Previewing Your Changes        82

Other Languages        83

Before You Build: Final Checks        84

SECTION 6:

MANAGING YOUR SNUG PROJECT        85

Managing Your Snug Project        86

What Should Go in the snug Directory?        86

What Should Be Saved with the Project?        87

Using Git        87

Should snug.exe Be Committed?        87

A Practical Starting Point        88

Reproducible Builds        88

Automating the Build        89

SECTION 7:

TECHNICAL DETAILS        90

Snug Technical Details        91

What Snug Actually Builds        91

The Builder and the Launcher        92

Anatomy of the Windows Executable        93

The Java Application Remains a JAR        95

What Happens When the Executable Starts        95

Application Identity and the Cache        96

Finding a Java Runtime        99

Starting Java        101

When the Java Application Exits        101

Application Arguments        102

The Windows Manifest        103

Logging and Diagnostics        103

Troubleshooting a Launch        105

Code Signing Is Separate from Packaging        105

Why Snug Does Not Bundle Everything        106

Keeping the Layers Separate        106

Technical Details Will Evolve        108

SECTION 8:

APPENDICES        109

Command-Line Options Reference        110

Quick Overview: Common Builder Options        110

Command-Line Practical Reference        113

Snug Builder (snug.exe) Options Reference        116

Snug Preview (snug_preview.exe) Options Reference        134

Diagnostic Messages Reference        136

The codes        136

Input        136

Archives        137

Entry point        138

Dependencies        139

Bytecode        140

Resources        141

Localisation        141

Output and log        142

Internal        143

Building Snug from Source        144

Why Build Snug Yourself?        144

Before You Begin        144

Obtaining the Source Code        145

Understanding the Project Layout        145

Building the Complete Windows Release        146

Building Individual Components with Cargo        147

Running Tests and Checks        148

Checking the Result        148

Common Build Problems        149

Making Changes and Contributing        149

A Note About Versions        149

Definitions        150

Copyright, Licensing, and Third-Party Notices        157

Copyright Notices        157

Copyright and Licensing        157

Snug        158

Third-Party Software        158

About Snug        159

Why Is It Called Snug?        159

Afterword: On Documentation        160

End Plate        162