I’m working on a basic React application built with create-react-app. It’s just a frontend app with no backend parts. My company needs me to bundle this into a runnable JAR file using Maven if possible.
I discovered the frontend-maven-plugin and got it working with a sample project. The examples I found were for Angular but that’s not really an issue.
The main problem is that every solution I come across uses Spring Boot as the backend framework. I can’t seem to find a way to package just a frontend React app into an executable JAR without including Spring Boot. Since my app doesn’t have any backend code, adding Spring Boot feels unnecessary.
I tried setting up a new Maven project and adding my React code to it, then configuring the pom.xml file to create an executable JAR. However, this approach isn’t working for me.
Does anyone know how to package a standalone frontend React application into an executable JAR file without needing Spring Boot or any backend framework?
Creating a JAR file for a pure React application is not feasible since JARs are designed for Java applications that require the JVM. React applications are static files that need to be served by a web server. In my experience, when facing a similar situation, I discovered that management wasn’t looking for a true JAR but rather a single file that simplifies deployment. My solution was to build a minimal Java application utilizing Jetty to serve the static files from the React build directory. It’s worth confirming whether a JAR is genuinely required, as alternatives like Docker often serve front-end applications better by providing an easy deployment solution.
wait, are you sure they want a jar file? that’s pretty weird for a react app. did you ask why they specifically need a jar? maybe their deployment pipeline expects java artifacts or something. what happens when you run npm run build? could you just package that output differently?
your company’s confused about what they want. React apps are just html/css/js files that run in browsers - they’re not java code in jars. tell them you can zip up the build folder instead. or maybe they want it served somehow? then youd need a simple server wrapper like the other person said.