JBend
A Java backend written from the socket up
JBend is a small server framework in plain Java, with no framework or server library underneath it.
It has its own non-blocking socket server, HTTP and WebSocket implementations, a database layer with
callback queries, accounts and sessions, an operator console, and a config language that ties the pieces
together. One file, config/application.conf, describes an application: which servers start,
on which ports, with which of your classes handling them.
I wrote it between 2020 and 2022 to understand what frameworks do for you by doing it myself, and used it for a multiplayer game and a repair shop's ticket system. Version 2.0 (2026) is the release that reads its whole startup from configuration and is safe to leave running on the internet. The live demo is one JBend process serving two multiplayer games.
A complete application
app-id:hello webserver: listen 8080 home res/front
That is a working web server. ./run.sh starts it. Everything else is added the same way,
a block at a time:
dataserver: source localhost shop credentials shop_user s3cret login: sessions 7d websocket: listen 8081 handler com.shop.LiveUpdates app: class com.shop.NightlyReport
What is in the box
| Piece | What it does | Read |
|---|---|---|
| Launcher | Reads the config, builds one thread per block and starts them in order, each waiting for the one before to be ready. | How it fits together |
| Config language | Blocks and settings, comments, quoted values, values from environment variables. Errors are reported with line numbers before anything starts. | Configuration reference |
| Server | One thread and one selector per port. Partial reads, queued writes and slow clients are handled for every protocol. | The server core |
| HTTP | HTTP/1.1 with keep-alive, static files, routes, mounts, page variables, cookies, a handler hook and deferred responses. | Web server |
| WebSocket | RFC 6455: handshake, masking, fragmentation, ping/pong, origin checks. Text and binary. | WebSocket server |
| TCP | Line-based TCP, or your own framing. A WebSocket-to-TCP bridge and a host-routed proxy are built on the same core. | TCP, bridge and proxy |
| Database | One database thread with a queue. Queries are objects whose done() runs when the result is in. Prepared statements, automatic reconnect. | Database and queries |
| Accounts | Registration, login, sessions, lockout and bans, with PBKDF2 password hashes. Exposed as a small JSON API. | Accounts and sessions |
| CRUD | Experimental object mapping: a class's fields become a table's columns. | CRUD objects |
| Console | Operator commands typed into the terminal, and your own commands alongside them. | Console and caretaker |
Requirements
- Java 11 or newer (a JDK, to compile).
- MySQL or MariaDB, only if the application uses a
dataserverblock. The MySQL JDBC driver is included. - Nothing else. There are no other dependencies and no build tool beyond
javac.
Where things are
JBend/
build.sh, run.sh, init.sh build, run, first-time setup
universe/
config/ application.conf, routes.cfg, version.conf
res/front/ the default web root
res/lib/ the MySQL driver
src/com/ the source
demo/ the live demo application
docs/ these pages