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:
- Open the latest Snug release page and select the Windows x64 ZIP file from its Assets list:
https://github.com/synapticloop/snug/releases/latest/ - Extract the ZIP file to a folder.
The unzipped folder will have the following icons:
|
|
Builds Windows executables from Java applications |
|
|
Lets you build an executable by dragging a JAR file onto it |
|
|
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.
- 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.
|
|
Your folder should now look like the following:
|
|
- Drag the JAR file onto
Snug Quick Build.exe. - 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.
|
Image: The demonstration JAR being dragged onto |
- Wait for Snug Quick Build to finish creating the Windows executable. A new file named
Example Application Name.exeshould appear in the same folder. This is the default filename used by the Snug Quick Build helper. If no EXE appears, opensnug.build.logbeside the Quick Build helper in Notepad for the builder's diagnostic report.
|
|
IMPORTANT: Windows security warnings:
|
- Double-click the file
Example Application Name.exeto 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.
|
Image: The new application |
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
SECTION 2:
BUILDING WITH SNUG 16
Building an Application with Snug 17
Quick-Start: Hello Snug JavaFX 17
Packaging Your Own Application 22
SECTION 3:
CUSTOMISING THE SNUG USER EXPERIENCE 25
What Happens When Someone Double-Clicks? 26
Introducing the snug.options File 28
SECTION 4:
CONFIGURATION OPTIONS 34
How Snug Configuration Works 35
Changing the Cache Location 40
Application Instance Behaviour 45
Splash Screen Configuration 45
Launcher Messages and Localisation 48
Creating Localisation Files 50
Using a Different Options File 55
A Practical Configuration Workflow 57
SECTION 5:
CUSTOMISING LAUNCHER MESSAGES 60
Your First Message Change and Preview 61
Understanding Launcher Dialogs 62
Common Localisation Key Suffixes 67
The Runtime Installation Dialogs 67
Replacement Tokens and the Key Reference 75
Keys Without Replacement Tokens 80
Before You Build: Final Checks 84
SECTION 6:
MANAGING YOUR SNUG PROJECT 85
What Should Go in the snug Directory? 86
What Should Be Saved with the Project? 87
Should snug.exe Be Committed? 87
SECTION 7:
TECHNICAL DETAILS 90
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
When the Java Application Exits 101
Code Signing Is Separate from Packaging 105
Why Snug Does Not Bundle Everything 106
Keeping the Layers Separate 106
Technical Details Will Evolve 108
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
Understanding the Project Layout 145
Building the Complete Windows Release 146
Building Individual Components with Cargo 147
Making Changes and Contributing 149
Copyright, Licensing, and Third-Party Notices 157







