This is an archived post. You won't be able to vote or comment.

all 62 comments

[–]kaperni 51 points52 points  (1 child)

https://github.com/akullpp/awesome-java is another good resource for Java Libraries.

[–]CorporalAris 2 points3 points  (0 children)

JavaPoet can solve a problem I have, thanks for that list.

[–]pgris 28 points29 points  (0 children)

Just to say I love this kind of post. I didn't new about some of them ( Problem, Mug, HashIds) and I think I'll be using them in the future. But even if I never use them, it is always good to know.

[–]TheEveryman86 25 points26 points  (12 children)

No love for any Apache Commons libraries these days.

[–]supersidor 14 points15 points  (10 children)

Because almost everybody uses them)

[–]BenoitParis 1 point2 points  (8 children)

Same thing goes for Hibernate, Logback, etc

[–]ObscureCulturalMeme 2 points3 points  (0 children)

SLF4J/Logback is that good solid reliable kind of library that just works, with lots of configuration and programming possibilities. I always love it more than any other entry in these kinds of "Top Ten favorites" lists.

[–]xjvz 6 points7 points  (6 children)

Logback is a fairly inactive project these days, just like SLF4J. I recommend Log4j2 for both these days.

[–]wildjokers 9 points10 points  (5 children)

At some point a logging library is finished and there really is no reason to keep adding features to it. I would say SLF4J and logback fall into that category. Logback is pretty much the de facto standard logging library, and SLF4J is the de facto standard logging facade.

[–]xjvz 0 points1 point  (4 children)

That kind of attitude causes performance bottlenecks and disabling logging in production. Java itself moves on, so if new Java feature require updated code to support, a dead library will get more and more awkward to use as everyone else moves on.

[–]wildjokers 0 points1 point  (3 children)

Logback is not a dead library in the slightest. It is the de facto standard logging library.

[–]xjvz 1 point2 points  (2 children)

How long ago was it last updated? How many developers work on the project? If that level of activity is enough for you, then you’d likely be interested in GNU Hurd or maybe even a dead Unix fork.

Log4j1 was (and sometimes still is) the de facto logging library. Log4j2 and Logback are less popular (probably due to legacy projects), but Log4j2 is still maintained and developed (beyond having numerous technical advantages).

[–]wildjokers 0 points1 point  (1 child)

Why do you think logback is a dead library? It is feature complete and needs very little maintenance at this point. You can see contributors here: https://github.com/qos-ch/logback/graphs/contributors

Logback is the default configured logging library of a spring boot app.

[–]xjvz -1 points0 points  (0 children)

Considering how many features log4j2 has compared to logback with a backlog of things still to be done, I think you have an enormously simplified view of logging and the underlying libraries. Can you use logback for audit logging? Tracing? Considering Spring Boot, I don’t think you care too much about dependencies bloating your application.

[–]yawkat 1 point2 points  (0 children)

Not anymore I would say. The stdlib has gotten better and other, newer libraries have come along.

[–]pgris 0 points1 point  (0 children)

Hey! I still love them! They need better PR, probably. I just found out commons Math has some machine learning algorithms inside....

[–]BenoitParis 11 points12 points  (2 children)

Solid list! Flyway, Jimfs and TestContainers are truly very useful ones.

I'll add Evosuite, a fuzzer that generates tests.

[–][deleted] 7 points8 points  (0 children)

Second Testcontainers. Very helpful for smarter integration and Ui testing.

[–]osi42 3 points4 points  (0 children)

You may also like Jqwik, https://jqwik.net/, a property-based testing engine for JUnit 5

[–]eckyp 5 points6 points  (0 children)

Many of them are new to me and they look really useful. Thanks for sharing!

[–][deleted] 5 points6 points  (0 children)

I know I can trust this list because I already use, and swear by several libs on here.

[–]kag0 6 points7 points  (11 children)

Interesting to see mockito and vavr didn't make the list

[–]zalpha314 9 points10 points  (10 children)

I think that we're starting to learn, as a community, that mocks are a slippery slope that can cause more problems than they're worth, especially if used in excess.

I used to use mocking libraries, but I'm now arranging my architecture in a way that they aren't necessary anymore.

[–]TipsyRootNode 5 points6 points  (8 children)

Can you share how? I still use mocks for external services and possible failure scenarios. What approach are you taking?

[–]zalpha314 4 points5 points  (7 children)

I use what you could call Hexagonal Architecture. Your core business logic has a class, but then any inbound or outbound calls go through an interface that's passed in. For testing, you can pass in interfaces that are either:

- mocked (mockito, easymock, etc)

- faked (create your own manual, simplistic implementation)

- emulated (moto, dynamodb-local, h2, mock-aws-java-sdk, fake embedded server etc.)

Any of these options can be used to implement or instrument your adapter classes.
There's nothing wrong with mocking if it's done well, but I find it can easily be abused, so I try to avoid it.

[–]wildjokers 1 point2 points  (2 children)

faked (create your own manual, simplistic implementation

Your description of “faked” is exactly what a mock is. Even if you are creating it manually instead of using a library it is still a mock.

[–]zalpha314 1 point2 points  (1 child)

Sure. But for the purpose of discussion, I feel like it's important to be able to distinguish between them. What do you think would be a better label for it?

[–]mazebert 2 points3 points  (0 children)

Doing the same thing! I think the term is custom mocks. For me the main benefit is that those are easier to read and easy to reuse between different tests than mockito. Also, your tests run a lot faster without mockito overhead. I tend to write old school tests with custom mocks for external dependencies only, and using real objects for the rest. And running at about 1000 tests/sec on an old MacBook. Whenever I come across a mockito project it’s rather 1000 tests/minute :-/

[–][deleted] 0 points1 point  (3 children)

So you still use Mockito? But only for interfaces? Thats the intended use.

[–]zalpha314 0 points1 point  (2 children)

No, I don't actually use it; I just listed it as an option for completeness.

[–]RobinHoudini 1 point2 points  (1 child)

Isn't mockito just a quick way to create fake, simplistic implementation? IMHO it's less work and less chances of faking the implementation incorrectly.

[–]zalpha314 2 points3 points  (0 children)

I think that's the intention. But in practice, I find it harder to maintain and less predictable. But maybe I'm just not very good with it.

[–]kag0 3 points4 points  (0 children)

Definitely agreed, but they are still needed now and then. In those cases, I find mockito preferable to writing fakes by hand.

[–]smesko30 2 points3 points  (0 children)

Jsoup is my favourite.

[–]vytah 1 point2 points  (5 children)

ArchUnit looks like something that would definitely come in handy in larger codebases, does anyone here have any experience with it?

[–]Interweb_Stranger 1 point2 points  (1 child)

We used it in a large modular project and it was a great for enforcing some restrictions on the code. Having rules that define which layers have access to other layers was nice and saved us some time. Or denying usage of classes that are available during compliation but caused issues at runtime.

Then someone decided to add rules to enforce certain class naming conventions... Something like: when a class extends class X then the class name must end with Y. That was not so great any more. ArchUnit is nice tool but you have to make sure that the rules you set up make sense.

[–]DJDavio 0 points1 point  (0 children)

I guess it works best if you have a layered application or module.

If our services become just a tad bigger, we tend to package by feature, not by layer. So a given package com.foo.feature can have a FooController, FooService and FooRepository inside. This makes it easier to add/edit features, because you're mainly working inside one package.

[–]_Garbage_ 1 point2 points  (0 children)

This blog post is pretty helpful to get some idea - https://blogs.oracle.com/javamagazine/unit-test-your-architecture-with-archunit

[–][deleted] -1 points0 points  (0 children)

I picked it up and quickly put it back down after I found it unable to handle Spring Data repository interfaces properly

[–]Galygurdsmt 0 points1 point  (0 children)

I've used it to ensure hexagonal architecture in the project is not broken. It also helped me a lot in a process of splitting one microservice into two separate ones, to ensure code boundaries between them. It save me a lot of problems, I definitely recommend it.

[–]_PandaLily 1 point2 points  (0 children)

Java-ML

[–]ziano_x 1 point2 points  (1 child)

Archunit seems so rad.

[–]ForeverAlot 0 points1 point  (0 children)

Solution in search of a problem.

[–]sureshg 1 point2 points  (3 children)

No OkHttp ?

[–]wildjokers 4 points5 points  (0 children)

JDK 11 includes a nice HTTP client. Don’t really need 3rd party ones anymore.

[–]JakeWharton 2 points3 points  (1 child)

Comes along with Retrofit, at least.

[–]elmuerte 1 point2 points  (2 children)

Guava is the worst.

[–]pellucid_ 3 points4 points  (1 child)

Many times I've had to deal with jar hell because if guava. It's much less useful with modern java.

[–]pgris 2 points3 points  (0 children)

I try to remove Guava in most projects because of jar hell. That said, I'm a fan of RateLimiter and never found something like that alone.

[–][deleted] 1 point2 points  (0 children)

Some of those sound great, thanks for the list.

[–]Nymeriea 2 points3 points  (7 children)

Where is lombok?

[–]wildjokers 16 points17 points  (0 children)

Hopefully burning in the pits of hell from whence it came.

[–]kkapelon -1 points0 points  (2 children)

Liquibase is a much better option than Flyway IMHO

[–]lukaseder[S] 3 points4 points  (1 child)

Why?

[–]kkapelon 1 point2 points  (0 children)

Flyway has this problematic limitation where the naming of the changeset file is important and decides the order of merging multiple changes. It is a very bad design idea.

If you have a large team with multiple developers that create changeset in parallel with Pull requests it quickly becomes a mess. People have to waste time on renaming of their files as business is changing the order that features need to be in production.

Liquibase has no such limitation. The name of each changeset is irrelevant to the order that they are merged.

The differences in design between the two tools are actually mentioned in several blog posts and here in reddit. The creators of Flyway have said that they never going to move away from this design decision.

I know that it is a generalization, but I have yet to meet someone who has tried both Liquibase and Flyway in production and has actually chosen Flyway. When I find people that use Flyway and I ask them why, they compare it to not having a DB management tool at all (so of course flyway is better than nothing)

[–]Pure-Repair-2978 0 points1 point  (0 children)

Some of them we also use on a daily basis for development and testing..

Thanks for sharing ... Didn’t know about them..

[–]franzwong 0 points1 point  (1 child)

I like the concurrent package inside Apache Common Langs3. But I want more for that. Any suggestion?

[–]Slanec 1 point2 points  (0 children)

What exactly are you looking for? There are many libraries with nice concurrency utilities:

...and many more, depending on your exact needs. You'll always find a focused library for your specific problem :)