<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/adam-bien-s-blog-mpjb4fu8k" -->

---
title: adam bien's blog | daily.dev
description: zws is a lightweight development web server implemented in a single Java 25 source file, built on top of the JDK's built-in HTTP server. It serves static files...
canonical: https://daily.dev/posts/adam-bien-s-blog-mpjb4fu8k
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: adam bien's blog | daily.dev
og:description: zws is a lightweight development web server implemented in a single Java 25 source file, built on top of the JDK's built-in HTTP server. It serves static files...
og:url: https://daily.dev/posts/adam-bien-s-blog-mpjb4fu8k
og:image: https://api.daily.dev/og/posts/mPJB4fu8k.png
og:image:alt: adam bien's blog
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# adam bien's blog

**[Adam Bien](https://daily.dev/sources/adam-bien)** · 2 min read · 1 upvotes · 0 comments

## Summary

zws is a lightweight development web server implemented in a single Java 25 source file, built on top of the JDK's built-in HTTP server. It serves static files with no-cache headers and supports two key features: live reload via Server-Sent Events and WatchService (injecting a one-liner script into HTML pages that triggers a browser refresh on file changes), and SPA routing fallback that serves index.html for extensionless paths not found on disk. No dependencies, no build step, no WebSockets — just Java 25 and standard web APIs.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://adambien.blog/roller/abien/entry/zws_live_reload_and_spa_routing_in_a_single_java_25_file>

## Questions this post answers

### How can I add live reload to a static site without using any JavaScript build tools or WebSockets?

A single Java 25 source file called zws can serve this purpose: it watches a directory with the WatchService API and injects a one-line script using Server-Sent Events into every served HTML page, so the browser reloads automatically whenever a file changes. The SSE connection is kept open on a virtual thread, requiring no WebSockets, no client library, and no build step.

_Developers wiring up minimal dev tooling can find practical Java setups like this one on daily.dev._

### How do I serve a single page application with client-side routing from a plain Java HTTP server without a framework?

Using the zws tool's --single flag, GET requests for extensionless paths that don't exist on disk are answered with index.html, letting client-side routes like /add work on deep links and page reloads. Requests that include a file extension still return 404, so typos in file paths remain visible instead of being silently swallowed.

_Teams evaluating lightweight SPA-serving options can track approaches like this on daily.dev._

## Similar posts on daily.dev

- [foojay – a place for friends of OpenJDK](https://daily.dev/posts/foojay-a-place-for-friends-of-openjdk-fe135kidv) · Foojay.io · 0 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#java](https://daily.dev/tags/java), [#server-sent-events](https://daily.dev/tags/server-sent-events)

[View this post on daily.dev](https://daily.dev/posts/adam-bien-s-blog-mpjb4fu8k)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"adam bien's blog","url":"https://daily.dev/posts/adam-bien-s-blog-mpjb4fu8k","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/adam-bien-s-blog-mpjb4fu8k"},"datePublished":"2026-07-15T06:08:01.344Z","dateModified":"2026-09-14T07:00:33.735Z","description":"zws is a lightweight development web server implemented in a single Java 25 source file, built on top of the JDK's built-in HTTP server. It serves static files...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d365e8cabb5d95ba36aaa092c23f211d?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d365e8cabb5d95ba36aaa092c23f211d?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Adam Bien","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Adam Bien","logo":"https://media.daily.dev/image/upload/s--CInnAL-q--/f_auto,q_auto/v1773644276/logos/adam-bien?_a=BAMAMiiu0","url":"https://daily.dev/sources/adam-bien"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/adam-bien-s-blog-mpjb4fu8k","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,java,server-sent-events","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Adam Bien","item":"https://daily.dev/sources/adam-bien"},{"@type":"ListItem","position":3,"name":"adam bien's blog"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/adam-bien-s-blog-mpjb4fu8k#faq","mainEntity":[{"@type":"Question","name":"How can I add live reload to a static site without using any JavaScript build tools or WebSockets?","acceptedAnswer":{"@type":"Answer","text":"A single Java 25 source file called zws can serve this purpose: it watches a directory with the WatchService API and injects a one-line script using Server-Sent Events into every served HTML page, so the browser reloads automatically whenever a file changes. The SSE connection is kept open on a virtual thread, requiring no WebSockets, no client library, and no build step. Developers wiring up minimal dev tooling can find practical Java setups like this one on daily.dev."}},{"@type":"Question","name":"How do I serve a single page application with client-side routing from a plain Java HTTP server without a framework?","acceptedAnswer":{"@type":"Answer","text":"Using the zws tool's --single flag, GET requests for extensionless paths that don't exist on disk are answered with index.html, letting client-side routes like /add work on deep links and page reloads. Requests that include a file extension still return 404, so typos in file paths remain visible instead of being silently swallowed. Teams evaluating lightweight SPA-serving options can track approaches like this on daily.dev."}}]}
```

