Dev Tools
中文

Jodd: A Swiss Army Knife for Java Developers, Zero Dependencies

A review of Jodd, a lightweight Java utility set and micro-framework collection with 4000+ stars, covering HTTP client, JSON parser, IOC container, HTML parser, and more — all with zero dependencies and high modularity.

javamicro-frameworkutilityhttp-clientjson-parserioc

[广告位: article-top] 请在 .env 中配置至少一个广告平台

I’ll be honest — the Java ecosystem isn’t short on utility libraries. But finding one that balances “lightweight” and “comprehensive” as well as Jodd does? That’s rare.

What caught my eye first was the project description: “Zero dependencies. Use what you like.” In an era where Maven dependency trees routinely run dozens of levels deep, that kind of restraint feels almost rebellious.

Where It Came From

Jodd was born in 2003, created by Igor Spasic who wanted to give Java developers an “alternative but practical” toolkit. Over 20 years, it evolved from a single utility library into a collection of more than a dozen micro-frameworks, accumulating over 4,000 stars on GitHub.

The core philosophy is simple: each module is small enough to solve one problem, and none of them force dependencies on each other. Need an HTTP client? Just pull in jodd-http. Need JSON parsing? Just jodd-json. Don’t want a Spring-style monolith? No problem.

That said, the project is in a transition phase. Starting with v6, modules were split into separate repositories. The old monorepo mostly keeps historical versions. Core modules like HTTP, JSON, and Petite are still actively maintained, but components like the Madvoc MVC framework are essentially in maintenance mode.

Three Modules That Stuck With Me

1. HTTP Client: Raw Enough, Convenient Enough

Jodd’s HTTP module takes a “small and raw” approach, built directly on Java Sockets without pulling in heavy dependencies like Apache HttpClient or OkHttp.

// Simple GET request
HttpResponse response = HttpRequest
    .get("https://api.example.com/users")
    .send();
System.out.println(response.bodyText());

// POST form data
HttpResponse response = HttpRequest
    .post("https://api.example.com/login")
    .form("username", "admin")
    .form("password", "secret")
    .send();

// File upload
HttpRequest request = HttpRequest
    .post("https://api.example.com/upload")
    .form("file", new File("report.pdf"))
    .form("description", "Monthly report");
HttpResponse response = request.send();

The API uses a fluent style, and chaining calls feels natural. It handles sessions, custom headers, and file uploads. For projects that don’t want to pull in OkHttp or Apache HttpClient, this is a refreshingly clean choice.

2. JSON Parser: Lighter Than Gson, Simpler Than Jackson

Jodd JSON follows a “good enough” philosophy. It doesn’t support Jackson’s complex annotation system, but for everyday serialization and deserialization, it gets the job done.

// Serialization
Book book = new Book();
book.setName("Jodd in Action");
book.setYear(2018);

String json = JsonSerializer.create()
    .include("authors")
    .serialize(book);

// Deserialization
Book parsed = new JsonParser()
    .parse(json, Book.class);

The .include() method lets you precisely control which fields participate in serialization, and .exclude() does the opposite. For simple REST API interactions, this parser is significantly lighter than Jackson and boots faster too.

3. Petite: IOC Without the XML

If you’re tired of Spring’s verbose configuration, Petite might surprise you. It’s purely annotation-driven — zero XML.

@PetiteBean
public class UserService {
    @PetiteInject
    private UserRepository userRepository;

    @PetiteInitMethod
    public void init() {
        // initialization logic
    }
}

// Start container and scan classpath
PetiteContainer petite = new PetiteContainer();
new AutomagicPetiteConfigurator(petite).configure();

// Get bean
UserService service = petite.getBean("userService");

Constructor injection, field injection, and method injection are all supported, along with Singleton, Prototype, ThreadLocal, and other scopes. For small-to-medium projects, Petite can fully replace Spring’s IOC container, and it starts up way faster.

Getting Started

All Jodd modules are published on Maven Central. Just pull in what you need:

<!-- HTTP client -->
<dependency>
  <groupId>org.jodd</groupId>
  <artifactId>jodd-http</artifactId>
  <version>6.3.0</version>
</dependency>

<!-- JSON parser -->
<dependency>
  <groupId>org.jodd</groupId>
  <artifactId>jodd-json</artifactId>
  <version>6.3.0</version>
</dependency>

<!-- IOC container -->
<dependency>
  <groupId>org.jodd</groupId>
  <artifactId>jodd-petite</artifactId>
  <version>6.3.0</version>
</dependency>

Runs on JDK 8 and up. Each JAR is only a few dozen to a hundred-something KB — great for projects sensitive to package size.

Pros and Cons

Pros:

  • Zero dependencies, each module works standalone without bloating your dependency tree
  • Tiny package size, ideal for size-sensitive scenarios like Android or serverless functions
  • Clean and intuitive API design with a low learning curve
  • BSD license, completely free for commercial use

Cons:

  • Community activity is modest. Only 2 open issues and 0 PRs on GitHub, which suggests people use it but don’t contribute much
  • Documentation is scattered across sub-sites without a unified entry point, making it a bit annoying to navigate
  • Some modules like the Madvoc MVC framework have stopped new feature development and are in maintenance mode
  • Almost zero integration with the Spring ecosystem. If you’re already using Spring, switching over isn’t trivial

Who Should Use It

I think Jodd fits these kinds of developers best:

  • Building small tools or scripts and don’t want to pull in a heavy framework like Spring Boot
  • Sensitive to dependency tree size, such as Android development or cloud function scenarios
  • Looking for a JSON library that’s lighter than Gson/FastJSON and simpler than Jackson
  • Learning IOC/DI principles — Petite’s source code is way more readable than Spring’s

Verdict

Jodd isn’t the kind of project that makes you go “wow.” But it’s like a Swiss Army knife — it sits in your bag without taking up space, and when you need it, it just works. Behind those 4,000+ stars is over 20 years of quiet dedication to the Java ecosystem.

If you’re looking for a lightweight, zero-dependency, pick-and-choose Java toolkit, Jodd is worth spending half an hour on.

Rating: ⭐⭐⭐⭐ (minus one star for scattered docs and community activity)

[广告位: article-bottom] 请在 .env 中配置至少一个广告平台

Related Posts