Embeddable Java Web Framework (EJWF) is a Java project template for building a website with a tiny footprint. It is suitable for a sidecar-style website embeddable on a larger JVM system and a standalone lightweight website.
The main selling point of EJWF is that it comes with productive and useful conventions and libraries such as:
In contrast, most of the lightweight web frameworks focus on being a bare metal web server serving HTML and JSON. They don't provide support for any frontend framework like React or Svelte; you would have to do it yourself. This is exactly what EJWF provides.
Initially, EJWF was built as a foundation for Backdoor, an embeddable sidecar-style JVM-based database administration tool, where you can embed it into your larger application like SpringBoot or PlayFramework.
npm install to install all dependencies../gradlew run to run the web server.npm run hmr in order to hot-reload the frontend code changes.EJWF is a template repository with collections of libraries and conventions. It's important that you understand each build process and are able to customize to your needs.
Here's how you can build your fat JAR:
./gradlew clean. This step is IMPORTANT to clean out the previous versions../node_modules/.bin/postcss ./frontend/stylesheets/tailwindbase.css --config . --output ./src/main/resources/assets/stylesheets/tailwindbase.cssENABLE_SVELTE_CHECK=true ./node_modules/webpack/bin/webpack.js --config ./webpack.config.js --output-path ./src/main/resources/assets --mode production./gradlew shadowJarThe far JAR is built at ./build/libs/embeddablee-java-web-framework-VERSION.jar
You can run your server with: java -jar ./build/libs/embeddable-java-web-framework-VERSION.jar
To publish to a Maven repository, please follow the below steps:
./build/staging-deploy by running rm -rf ./build/staging-deploy./gradlew publish~/.jreleaser/config.toml with JRELEASER_MAVENCENTRAL_USERNAME and JRELEASER_MAVENCENTRAL_PASSWORD./gradlew jreleaserDeployAfter you've built your application on top of this framework and publish your fat jar, your customer can follow the below steps in order to embed your website into their applications.
<dependency>
<groupId>io.github.tanin47</groupId>
<artifactId>embeddable-java-web-framework</artifactId>
<version>0.1.1</version>
</dependency>
var main = new tanin.ejwf.Main();
main.start(9090);
Minum is the smallest web framework written in pure Java with zero dependencies. One of its goals is to avoid reflection and magic, which is great for embeddability.
I've looked at a couple other options:
The above options also have external dependencies.
Some services like Render or Heroku allow only one port to be served.
What you can do here is to designate a path e.g. /ejwf where it proxies to EWJF.
An example proxy code that requires no dependency would look like below:
// In your endpoint of /ejwf
var client = HttpClient.newHttpClient();
var httpRequest = HttpRequest
.newBuilder()
.uri(URI.create("http://localhost:9090" + path)) // The path without /ejwf
.method("GET", HttpRequest.BodyPublishers.ofByteArray(new byte[0])) // Set the method and body in bytes
.headers(/* ... */) // Forward the headers as-is.
.build();
var response = client.send(httpRequest, HttpResponse.BodyHandlers.ofByteArray());
// Return the response as-is