Tooling beginner

Built-in HTTP server

Java 18 includes a built-in minimal HTTP server for prototyping and file serving.

✕ Java 8
// Install and configure a web server
// (Apache, Nginx, or embedded Jetty)

// Or write boilerplate with com.sun.net.httpserver
HttpServer server = HttpServer.create(
    new InetSocketAddress(8080), 0);
server.createContext("/", exchange -> { ... });
server.start();
✓ Java 18+
// Terminal: serve current directory
$ jwebserver

// Or use the API (JDK 18+)
var server = SimpleFileServer.createFileServer(
    new InetSocketAddress(8080),
    Path.of("."),
    OutputLevel.VERBOSE);
server.start();
🚀

Zero setup

Run jwebserver in any directory — no installation, config, or dependencies needed.

📦

Built into the JDK

Ships with every JDK 18+ installation, always available on any machine with Java.

🧪

Great for prototyping

Serve static files instantly for testing HTML, APIs, or front-end development.

Old Approach
External Server / Framework
Modern Approach
jwebserver CLI
Since JDK
18
Difficulty
beginner
Built-in HTTP server
Available

Available since JDK 18 (March 2022)

JDK 18 added a simple, zero-dependency HTTP file server accessible via the jwebserver command-line tool or the SimpleFileServer API. It serves static files from a given directory with no configuration needed. The CLI tool is ideal for quick prototyping, testing, and ad-hoc file sharing — no external dependencies or frameworks required. The API allows programmatic use with customizable handlers and output levels.

Share 𝕏 🦋 in