If you ever happen to ask yourself how to package your Spring Boot App as an .exe File for running in Windows (could that possibly happen :P ?!), then maybe the standard Oracle JDK javapackager could be something for you.
This is a simple example project to show how this is done
Clearly, if you want to package a Spring Boot app, you need one first. Start on spring initializr or simply take this project :)
It seems to be simple - but all those steps only run on a Windows Machine or VM and will fail on your Mac or Ubuntu :) So fire up one!
javapackager will be included in your jdk_xxx\bin Folder
All the packaging is done through the freeware Inno Setup installer for Windows programs - javapackager builds upon it, when creating an exe-File. Get the latest version here and be sure to have administrative rights! Refrain from just installing it on some machine, packaging the resulting Folder under C:\Program Files into a .zip and copy it to another Windows Box -> This will not work! You would get error messages, that are quite confusing like:
Bundler EXE Installer skipped because of a configuration problem: Main application jar is missing. javapackager deploy exe
Advice to fix: Make sure to use fx:jar task to create main application jar javapackager
...which will point you in a complete false direction! This is one of the worst error messages I have ever seen :P I just got through to this, by stumbling upon this blog post´s comments
mvn clean package
With our project, the command is something like this:
javapackager -deploy -native exe -outdir ./executable -srcfiles springboot2exe-0.0.1-SNAPSHOT.jar -outfile springboot2exe-0.0.1-SNAPSHOT -name springboot2exe-0.0.1-SNAPSHOT -title "Spring Boot 2 .exe" -appclass org.springframework.boot.loader.JarLauncher -v
The -appclass is not your Application.class with the main in it! You need to pick Spring Boot´s org.springframework.boot.loader.JarLauncher
You´ll find a springboot2exe-0.0.1-SNAPSHOT.exe inside your target/executable/bundles folder - install it and it will create a folder inside of C:\Users\YourUserHere\AppData\Local\JarLauncher, where the runtime folder holds a JRE and the app folder contains your fat.jar.
Start C:\Users\YourUserHere\AppData\Local\JarLauncher\springboot2exe-0.0.1-SNAPSHOT.exe - it´s named the same like the installer, but it´s the actual runnable .exe File you wanted. Just take a look inside your Windows Taskmanager:
javapackager is also capable of packaging DMG Files - read this post or google it :)