Say Hello To Snug
Chapter 7

The Snug Experience

Snug should let people double-click your application and get on with their work, without needing to understand JAR files or Java runtimes.

When the launcher does need to communicate, its prompts, icon, and splash screen should feel like part of your application.

What Happens When Someone Double-Clicks?

When someone double-clicks the Windows executable created by Snug, they start the Snug launcher built into it, rather than the Java application directly.

The launcher checks what the application needs and prepares its files before starting Java. For the person using your application, there are two experiences worth considering: the first launch and later launches.

The Initial Launch

On the first launch, Snug checks for a suitable Java runtime before starting the application.

If a suitable runtime is unavailable, Snug can prompt the user to download the required components, as shown in Section 2: Building with Snug. The prompt should clearly belong to your application.

Note: Snug's runtime download behaviour can be configured. See Section 4: Configuration Options for the available settings.

The Normal Launch

On later launches, Snug still checks that the required runtime and application files are available. When they are, it reuses them and starts the application without repeating the download. A configured splash screen can appear during startup.

This is the experience Snug aims to provide:

~ ~ ~ * ~ ~ ~

"Double-click the application.
The application opens."

~ ~ ~ * ~ ~ ~

The technical details required to make that happen belong behind the scenes.

Application Identity

Before choosing an icon or splash screen, decide how your application should be identified.

Two settings are particularly important:

  • Application name - The name people will recognise when they use your application.
  • Company name - The organisation or person responsible for the application.

Snug also uses these values internally to identify the application and manage its local files. Choose them carefully, particularly if you intend to distribute the application to other people.

Other details help give your application a consistent appearance: version information, an application icon, a startup splash screen, and launcher messages.

Together, these details help make your executable recognisable as your application, rather than simply another file someone has received.

Windows can also display information about your application when someone hovers over the executable in File Explorer or opens its Properties window.

File Explorer tooltip showing the executable’s description, company, file version, creation date and size.
Image: File Explorer tooltip showing application details.

The fields shown may vary with the Windows version and File Explorer settings.

Windows Properties window for snug-javafx-demo-windows.exe, showing its file type, description, location, size and dates. The Details tab is available at the top.
Image: Windows Properties showing executable details.

Before customising these details, let's bring your Snug settings together.

Introducing the snug.options File

As you customise your application, the number of options you give Snug may grow. Rather than typing them all out every time you build your executable, you can save them in a snug.options file.

This makes rebuilding your application much easier. Your settings stay together in one place, you can change them whenever you need to, and each new build uses the same configuration. You can also keep the file alongside your project so that you, or someone else, can build the application again without having to remember how it was originally put together.

The snug.options file is simply a plain-text file containing the options Snug uses when building your executable.

The easiest way to get started is to let Snug create an example options file. Open PowerShell in the folder where you are working and run:

Command(s)

.\snug.exe --init-options


Snug creates snug.options in the current folder, with settings and example values you can edit. Open it in Notepad or another plain-text editor and adjust the values for your application. If snug.options already exists, Snug will not overwrite it by default.

You can also create the file yourself in a plain-text editor. Make sure it is named snug.options, not snug.options.txt.

To practise branding the Snug JavaFX demonstration application, start with these three settings in snug.options. My Application and My Company are example labels; the input remains the demonstration JAR:

--input "snug-javafx-demo-windows.jar"
--name "My Application"
--company "My Company"

Save snug.options, then run .\snug.exe in PowerShell from the same folder as the snug.options file to build the executable. Double-click the resulting executable to test it.

Add a custom icon or splash screen using the examples below when you are ready.

Section 4: Configuration Options explains how Snug locates and reads this file, combines it with command-line options, and lists the available settings.

The Application Icon

An application icon helps people recognise your application in File Explorer, on the desktop, and in Windows dialogs. Every executable built with Snug has an icon.

IMPORTANT: Windows may cache an executable's icon using its filename. If File Explorer still shows the old icon after a rebuild, try a different output filename to check the new icon.

The Default Icon

If you do not provide your own icon, Snug uses its built-in default. That is fine while you are testing your application.

The default Snug application icon: the smiling jar mascot wearing a scarf, with a coffee cup pictured inside.
Image: Snug's default application icon.

Using Your Own Icon

To use your own icon, add a PNG or ICO image with the --icon option:

--icon <PNG|ICO>

For example, add the following line to snug.options:

--icon "snug\icon.png"

Snug accepts PNG and ICO files. Choose a simple image that stays recognisable at small sizes.

The same icon also appears in Snug's launcher dialogs, including those shown when runtime components are required or an error occurs. This helps the messages feel like part of your application.

The Executable Icon and the Java Window Icon

The icon supplied to Snug with --icon is embedded in the Windows executable and used by Snug's branded dialogs. It does not automatically set the icon displayed by the Java application's windows or its taskbar button. JavaFX and Swing applications usually manage those icons themselves. For a consistent appearance, use the same artwork for both.

For example, in JavaFX, after creating your Stage:

01

stage.getIcons().add(new Image("/app-icon.png"));


In Swing, after creating your JFrame:

01

02

03

04

05

frame.setIconImage(

    new ImageIcon(

        getClass().getResource("/app-icon.png")

    ).getImage()

);


Both examples assume
app-icon.png is included in the application's classpath. They are illustrative snippets, not complete programs. Snug does not modify or override the icon chosen by your Java application.

The Splash Screen

If an application takes a few seconds to open, a splash screen shows that it is starting. This is usually an image containing the application's name, logo, or other artwork.

Snug shows its native splash after preparing the application files and obtaining a suitable runtime, just before starting the JVM. It can appear before your Java application creates a window, but it does not cover the runtime-download flow.

For example, the snug-javafx-demo-windows.exe that is included in the release assets is configured to show the Snug demonstration splash screen while the application is being prepared and started.

Example Snug splash screen with the mascot and the message “Turning Java JARs into polished native apps.”
Image:
The Snug demonstration splash screen.

Should Snug or Your Java Application Display the Splash Screen?

A splash screen does not have to be provided by Snug; your Java application can display its own. This gives you a choice:

  1. Let Snug display the splash screen.

    Snug displays its splash just before starting the JVM, after preparing the application files and obtaining a suitable runtime. It can give feedback before your Java application creates its own window, but runtime-download dialogs appear first when a download is needed.
  2. Let the Java application display the splash screen.

    In this case, the splash screen is controlled by the Java application itself. It will be slower to show than a Snug generated splash screen and exactly how it looks and behaves is up to the developer who created the application.

~ ~ ~ * ~ ~ ~

You would not normally need both.

For a longer startup, Snug can show its native splash while the JVM starts. Your Java application can then display an animated screen or progress indicator.

~ ~ ~ * ~ ~ ~

Do You Need a Splash Screen?

Not necessarily.

If your application opens almost immediately, a splash screen may add little value and can make startup feel slower. If there is a noticeable delay, a splash screen can reassure the user that something is happening. Choose one because it improves the experience, not simply because Snug supports it.

Size and Duration

A splash screen should generally be large enough to be clearly visible without taking over the user's screen.

Choose an image that is easy to recognise and a display time that does not make startup feel unnecessarily slow. Section 4: Configuration Options covers the defaults and size-warning settings.

Configuring the Splash Screen

Add your image and a minimum display time to snug.options:

--splash "snug\splash.png"
--splash-ms 2500

Save the file and rebuild with .\snug.exe. This example displays your splash image for at least 2.5 seconds. See Section 4: Configuration Options for the full option reference.

For now, remember that the splash screen is part of your application's experience. It should look like it belongs to your application rather than advertising the tool that was used to package it.