This project is a starting point for wrapping any Java web app—like those using Spring Boot—inside Electron to create a native executable. It’s built entirely with Maven, and the repo comes with all the necessary configurations and some placeholders to help you get up and running quickly.
The idea for this project was heavily inspired by electron-java-app, but there are a few key differences:
- The build process is Maven-only, with Node being used indirectly.
- The Electron app includes an OpenJDK to run the Java web app.
The main goal here was to test out a idea, to combine Electron, a bundled JDK, and a Java web app in a Jar because I enjoy tinkering. Before using this in production, you’ll definitely want to evaluate if it fits your needs.
That said, there are some trade-offs. Electron is already resource-heavy, and adding both a JVM and an embedded web server on top of it makes it even more demanding. So, do you really need both a browser and OpenJDK just to run a Java web app as a desktop app? If sticking with Java is a must, options like Swing or JavaFX could be more efficient. But in some cases, this setup might still be useful—for example, as a temporary solution before moving to the cloud.
A few ways to improve this concept:
- Removing OpenJDK by using GraalVM native images.
- Replacing Electron with Tauri for a lighter setup.
- Long-term, as Progressive Web Apps (PWAs) evolve, the need for a browser might disappear entirely.
Right now, this project doesn’t include an updater, and logging has to be set up manually—definitely areas for future development.
master
-> Java 17java-8
-> Java 8
mvn clean install -Pproduction
The artifacts from the electron build will be put into:
target\electron\springboot-on-electron-darwin-x64
target\electron\springboot-on-electron-win32-x64
target\electron\springboot-on-electron-linux-x64
When using macOS or Linux, wine
is required to build windows
(check the maven build for further information).
When using Windows, admin privileges are required to build darwin
(check the maven build for further information).
Since not all your users have the right JVM available via classpath an OpenJDK 17 will be packed into the electron builds
When executing mvn clean install -Pproduction
by default the windows
(x64), darwin
(x64) and linux
(x64) will be built.
The rest is currently not supported but adding those shouldn't be too hard but some changes will need to be made at the following files: