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

PieceWhat it doesRead
LauncherReads 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 languageBlocks and settings, comments, quoted values, values from environment variables. Errors are reported with line numbers before anything starts.Configuration reference
ServerOne thread and one selector per port. Partial reads, queued writes and slow clients are handled for every protocol.The server core
HTTPHTTP/1.1 with keep-alive, static files, routes, mounts, page variables, cookies, a handler hook and deferred responses.Web server
WebSocketRFC 6455: handshake, masking, fragmentation, ping/pong, origin checks. Text and binary.WebSocket server
TCPLine-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
DatabaseOne database thread with a queue. Queries are objects whose done() runs when the result is in. Prepared statements, automatic reconnect.Database and queries
AccountsRegistration, login, sessions, lockout and bans, with PBKDF2 password hashes. Exposed as a small JSON API.Accounts and sessions
CRUDExperimental object mapping: a class's fields become a table's columns.CRUD objects
ConsoleOperator commands typed into the terminal, and your own commands alongside them.Console and caretaker

Requirements

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