Soklet

3 min read Original article ↗

The Java web ecosystem is missing a server solution that is dependency-free but offers support for Virtual Threads, Server-Sent Events, hooks for dependency injection, and annotation-based request handling. Soklet aims to fill this void.

Soklet provides the plumbing to build "transactional" REST APIs that exchange small amounts of data with clients. It is well-suited for building tool-backed agentic systems that stream results via SSE. It does not make technology choices on your behalf (but an example of how to build a full-featured API is available). It does not natively support Reactive Programming or similar methodologies. It does give you the foundation to build your system, your way.

Soklet is commercially-friendly Open Source Software, proudly powering production systems since 2015.


Design Goals

Design Non-Goals

  • SSL/TLS (your load balancer should provide TLS termination)
  • Traditional HTTP streaming
  • WebSockets
  • Dictate which technologies to use (Guice vs. Dagger, Gson vs. Jackson, etc.)
  • "Batteries included" authentication and authorization

Installation

Soklet is a single JAR, available on Maven Central.

JDK 17+ is required (or JDK 21+ for Server-Sent Events).

Maven

Gradle

Direct Download

If you don't use Maven or Gradle, you can drop soklet-2.0.2.jar directly into your project. No other dependencies are required.

Example Usage

Here we demonstrate building and running a single-file Soklet application with nothing but the soklet-2.0.2.jar and the JDK. There are no other libraries or frameworks, no Servlet container, no Maven build process - no special setup is required.

While a real production system will have more moving parts, this demonstrates that you can build server software without ceremony or dependencies.

Source Code

Want a better understanding of Soklet's capabilities? Start with Request Handling.

Want a minimum-viable "hello world" app you can easily clone and run? Check out the Barebones App.

Want to see how a real-world Soklet app looks? The Toy Store App covers topics like JSON marshaling, dependency injection, authentication/authorization, talking to a database, error handling, internationalization, and more.

Building and Running

You'll need to provide javac with these flags:

  • -parameters
  • -processor com.soklet.SokletProcessor

JDK 17+ is required.

If you need a JDK, Amazon provides Corretto - a free-to-use-commercially, production-ready distribution of OpenJDK that includes long-term support. Official Corretto Docker Images are also available.

It's recommended to use JDK 21+ to take advantage of Virtual Threads.

Build

Run

Test

Credits

Soklet stands on the shoulders of giants. Internally, it embeds code from the following OSS projects, all of which have licenses that are suitable for commercial use: