How to Convert a Java JAR into a Standalone EXE for JDK‑Free Installation
This guide walks you through converting a Spring Boot JAR into a Windows executable using exe4j and then packaging it with its bundled JRE into an installer via Inno Setup, enabling users to run the application on machines without any Java runtime installed.
Prerequisites
You need a compiled, bug‑free JAR file, the exe4j tool for converting JARs to EXE, and Inno Setup for creating an installer that bundles the JRE.
Creating the EXE with exe4j
Open exe4j and select the Java to EXE wizard. Provide a name and output path for the executable, then choose the launch mode. Enable the option to support both 32‑bit and 64‑bit systems. In the VM parameters field add -Dfile.encoding=utf-8. Configure the JRE section to include a local JRE directory so the generated EXE can run without a separate JDK/JRE installation. Select Client VM and finish the wizard. After compilation you will obtain demo.exe on your desktop.
Packaging with Inno Setup
Launch Inno Setup, create a new script, and fill in the application name and version. Accept the default settings for most pages, then add the previously generated demo.exe as the main file. Specify the output directory and the name of the installer (e.g., setup.exe). In the script, add a line to copy the local JRE into the installation folder:
Source: "YourLocalJREPath\*"; DestDir: "{app}\{#MyJreName}"; Flags: ignoreversion recursesubdirs createallsubdirsCompile the script; Inno Setup will produce setup.exe. When run, the installer copies the EXE and the bundled JRE, and you can optionally create a desktop shortcut.
Final Result
The resulting setup.exe can be distributed to users who do not have Java installed. After installation, they can launch the application directly from the shortcut or start menu, and it will run using the bundled JRE.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
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.
