Java libraries I like

November 2020 · Tallinn, Estonia · comments

The list was updated in 2020.

Everyone knows Spring and Hibernate, but there are other libraries and frameworks that are worth your attention. I pulled a list of 36 Java libraries that I like and use daily. Some of them are well-known; others are not so popular, yet very useful at work.

Java logo

Name About
ArchUnitA simple and extensible library for checking the architecture of your Java code via tests.
AssertJA library for writing fluent and rich assertions in Java tests.
AwaitilityA DSL that allows you to express expectations of an asynchronous system in a concise and easy to read manner.
ByteBuddyA library for creating and modifying Java classes during the runtime.
CaffeineA high performance, near optimal caching library based on Java 8 and a faster replacement of Guava Cache.
DaggerA compile-time dependency injection library with low or zero runtime overload. Works well with Google's Auto Factory.
EA AsyncEA Async adds async awaits to in the JVM and allows programmers to write asynchronous code in a sequential fashion.
FailsafeA lightweight, zero-dependency library for handling failures in Java 8+, with a concise API for handling everyday use cases and the flexibility to handle everything else.
FakerA library for generating fake data, useful when you're developing a new project and need some pretty data for showcase.
FlywayEvolve your database schema easily and reliably across all your instances.
Google Auto ServiceA library for automatic generation of java.utils.ServiceLocator META-INF metadata for any class annotated with @AutoService, avoiding typos, providing resistance to errors from refactoring.
GuavaA set of common libraries for Java, developed and maintained by Google.
Guava TestlibA set of testing utilities for collections, equals(), hashCode(), toString() etc.
HashidsHashids is a small open-source library that generates short, unique, non-sequential ids from numbers. Useful if you want to obfuscate and expose (non-critical) numbers via API.
ImmutablesImmutables generates simple, safe, and consistent value objects (data classes). It's more flexible than Google's AutoValue and Lombok.
JavalinA simple web framework for Java and Kotlin. My favorite alternative to Spring MVC.
JimfsAn in-memory file system for Java, super useful for unit testing, because you don't want to mock the file system.
jOOQA fluent API for typesafe SQL query construction and execution. My favorite alternative to Hibernate.
jOORA simple, intuitive, and fluent wrapper over Java Reflection API.
LogbookAn extensible Java library to enable complete request and response logging for different client- and server-side technologies.
MugA small Java 8 utilities library that complements Guava. Has useful classes such as Maybe.
NoExceptionA library for dealing with checked exceptions in lambdas. Supports sneaky throws.
NullAwayA tool to help eliminate NullPointerExceptions (NPEs) in your Java code with low build-time overhead.
ProblemA library that implements and proposes a common approach for expressing errors in REST API.
ProtonpackA small collection of Stream utilities, such as Streamable interface (useful when you want to stream repeatedly).
RestAssuredA DSL for writing powerful, maintainable tests for RESTful APIs.
RetrofitA type-safe HTTP client for Android and Java.
SelenideConcise UI tests in Java.
SpockSpock is a testing and specification framework written in Groovy. Probably the best way to write tests in Java.
Stateless4jA library for creating state machines and lightweight state machine-based workflows directly in Java code.
StreamExStreamEx simplifies and enhances Java Stream API.
TestContainersA library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
ThreeTen ExtraAdditional date-time classes that complement those in Java 8. (MutableClock, LocalDateRange etc.).
Verbal ExpressionsA library that helps to construct difficult regular expressions.
WireMockA flexible API mocking tool for fast, robust and comprehensive testing.
YaviA lambda based type-safe validation library.

💡 If you want to see and learn those tools in action, join my Effective Coding Principles and Patterns in Java 15 course.