Packaging a Spring Boot Application into a Windows EXE Installer with exe4j and Inno Setup
This guide walks through converting a functional Spring Boot JAR into a Windows executable with exe4j, then bundling the EXE, JRE, and dependencies into a single installer using Inno Setup, providing step‑by‑step screenshots, configuration tips, and the final script for seamless deployment on machines without a JDK.
This article explains how to turn a compiled Spring Boot JAR into a Windows executable and then create a self‑contained installer that includes the JRE, so the application can run on computers without a Java environment.
Prerequisites
A working JAR file that starts without errors.
exe4j – a tool that converts JAR files to EXE.
Inno Setup – a tool that packages the EXE, JRE and other resources into a single installer.
Download links and passwords for exe4j and Inno Setup are provided in the original post.
Step 1 – Convert the JAR to EXE with exe4j
Open exe4j, choose the "Java to EXE" wizard, set the input JAR (e.g., placed on the desktop), specify the output name and path, and select the appropriate launch mode. In the VM options field add -Dfile.encoding=utf-8 . Continue through the wizard, enabling 32‑bit and 64‑bit compatibility, and finish the configuration. The wizard produces demo.exe on the desktop.
Step 2 – Create the installer with Inno Setup
Start Inno Setup (File → New) and fill in the basic application information (name, version, etc.). Add the generated demo.exe as the main executable, then add the local JRE directory as an additional file set. When configuring the file entry for the JRE, use the following script line (wrapped in a code block):
Source: "自己本地JRE路径\*"; DestDir: "{app}\{#MyJreName}"; Flags: ignoreversion recursesubdirs createallsubdirsProceed through the remaining wizard pages, accepting the defaults for language, output folder, and installer name. At the final step, compile the script; Inno Setup will generate setup.exe .
Step 3 – Test the installer
Run the produced setup.exe , follow the installation prompts (optionally creating a desktop shortcut), and verify that the installed program launches correctly. The installer now contains both the EXE and the bundled JRE, allowing the application to run on machines without a pre‑installed JDK.
By following these steps, developers can distribute Spring Boot backend services as easy‑to‑install desktop applications for non‑technical users.
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.