zws: Live Reload and SPA Routing in a Single Java 25+ File 📎
zws is a development web server in a single Java 25 source file on top of the built-in jdk.httpserver. It serves static files from a directory, sends no-cache headers, and opens the browser. Java 25 is the only prerequisite:
curl -O https://raw.githubusercontent.com/AdamBien/zws/main/zws chmod +x zws ./zws [root-directory] --live --single
Without root-directory, zws serves the current directory.
With --live, zws watches the site root recursively with WatchService and injects a single line into every served HTML page:
The /reload endpoint speaks server-sent events: the connection stays open on a virtual thread, and every file change pushes an event that reloads the page. Save a file, the browser refreshes. Pure web standards, no WebSockets, no client library, no build step.
With --single, zws serves Single Page Applications with client-side routing: GET requests for paths that do not exist on disk and have no file extension (routes like /add) are answered with index.html, so deep links and reloads reach the application. Requests with a file extension still return 404, keeping typos visible.
The flags are independent and compose: with both active, SPA-fallback responses reload as well.
The airails.dev skills bundle zws as the development server: the generic web-conventions skill ships a copy, web-static serves generated sites with it for authoring (--live) and for the verification loop, and web-components relies on --single for SPA routing during development.
zws is part of z, a collection of zero-dependency Java projects.