Skip to content

Package your Java Web Application with Electron + OpenJDK only using Maven

License

Notifications You must be signed in to change notification settings

appreciated/maven-springboot-electron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven + Spring Boot + Electron (+ OpenJDK)

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.

Proof of Concept

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.

Branches

  • master -> Java 17
  • java-8 -> Java 8

How to build

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).

Shipping OpenJDK

Since not all your users have the right JVM available via classpath an OpenJDK 17 will be packed into the electron builds

Documentation

Build

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:

Pull requests are welcome

About

Package your Java Web Application with Electron + OpenJDK only using Maven

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •