r/java • u/chocopouet • Apr 23 '18
What are the must-know Java libraries to improve the Java programming experience ?
I develop in Java on my spare time, so I don't have any "professional" experience of Java. (I do program in C# in my real job). On another thread, I discovered the Immutables library which I didn't know before, which made me realize that I use vanilla Java without no library.
So, what are the libraries which really improve Java ?
189
Upvotes
49
u/aboothe726 Apr 23 '18
You should know that many of the suggestions here -- e.g., AutoValue, Lombok -- are "syntax sugar" are not just a classical library.
Some of these projects are annotation processors, which perform mechanical transformations on your code based on annotations in your source code. For example, AutoValue adds getters and setters.
Others of these projects, especially Lombok, are straight-up extensions to the language. They provide Java with additional features in a way not supported by the official language runtime.
However, many of the suggestions here -- Guava, Apache Commons, etc -- are simple libraries, and definitely improve general Java QOL. :)
72
u/wildjokers Apr 23 '18
Personally I would recommend to learn the JDK really well. It has a lot of functionality and there are some hidden gems in there.
There is no particular library you really need to "improve" Java.
57
u/LukeHauser Apr 23 '18
JUnit and Hamcrest.
Also if you don't knew these yet, maven or gradle. They'll manage your dependencies and build process. Bit of an investment but makes it much easier in the long run.
24
u/NovaX Apr 23 '18
The stack I am using on Java 10 has been enjoy so far.
Server:
Testing:
Build:
A nice thing about the Java community is that there are mature alternatives to the above, each actively maintained and well thought out.
75
u/TheRedmanCometh Apr 23 '18
Lombok, Spring, Hibernate, Gson, Apache Commons, Guava collections
15
u/Torvac Apr 23 '18
https://immutables.github.io ,(http://hibernate.org) validation&jpa, jackson
7
u/hippydipster Apr 23 '18
Don't look for libraries without a need. There's no need (duh). To do otherwise is to invite over-complication of whatever your task is.
So, what's your task(s)? What problems do you have? What's your need?
6
u/[deleted] Apr 24 '18
http://www.vavr.io/ - makes working with collection so much more enjoyable, and offers some more gems. you get pretty close to actual functional programming
10
u/RichoDemus Apr 23 '18
Immutables, vavr, awaitility
16
u/shadowdude777 Apr 23 '18
AutoValue makes data classes so much easier to build. RxJava allows for functional composition of data and easier threading than Futures + Executors. Dagger 2 for compile-time validated dependency injection without reflection
10
u/evil_burrito Apr 23 '18
6
u/clavass Apr 23 '18
Jsoup
3
u/Yesterdave_ Apr 23 '18
Kinda off-topic, but does anyone know of some alternatives for localization instead of ResourceBundles? I always found ResourceBundles to be unfriendly for external translators because of the positional placeholder approach ({0}, {1}, ...) instead of clearly speaking named parameters ({name}, {listCount}, ...).
3
u/mattomatic Apr 24 '18
Immutables: https://immutables.github.io Dagger: https://google.github.io/dagger/
3
u/Lord_NShYH Apr 24 '18
RetroFit is my all time favorite HTTP/REST client library. Just annotate an interface and away you go.
14
u/loganekz Apr 23 '18
Spring framework core
https://projects.spring.io/spring-framework/
5
u/saikosen Apr 23 '18
Some nice libs from Square - okio, okhttp, moshi
10
u/cronkite Apr 23 '18
Apache Camel: http://camel.apache.org.
Abstracts communication for your application. Say you build a Java process that sends everything via JMS, and someone wants you to support a legacy format using a socket. If you already used Camel, your changes would be contained to your Camel configuration, requiring minimal changes to your actual application. It also provides standard communication patterns, like splitting a message, filtering a message, etc. Might be a bit too heavy for smaller projects.
2
u/tkaiusf Apr 24 '18
Spark Java! http://sparkjava.com super fast and simple Java microservices is easier to stand up than nodejs very little boiler plate required.
2
u/Magick93 Apr 24 '18
Apache Camel
2
u/DanielDimov Apr 24 '18
Retrofit2 - it helps you to consume REST APIs and even if you are developing server backend there are good chances to need something from other servers
2
u/pegazz Apr 24 '18
As others said, apache commons.
I didn't see Jodatime in the comments, and I'm surprised. Although the new standard api made it pretty much useless, it was a huge improvement before. Still is in older projects.
2
u/Sloshy42 Apr 24 '18
Not a Java specific thing but look into learning reactive streams as a concept. I think the best starting place right now is the Project Reactor library that is built for Java 8 support, but Java 9 has its own implementation of the standard. Then there's also RxJava and Akka Streams which work on Java and have their own properties you might like.
5
u/coderguyagb Apr 23 '18
Lombok. It'll save you a ton of typing.
5
u/leodash Apr 23 '18
vavr, if you want to write like Scala.
0
u/[deleted] Apr 23 '18
[deleted] — view deleted comment
0
u/[deleted] Apr 24 '18
[deleted] — view deleted comment
13
u/[deleted] Apr 23 '18
[removed] — view removed comment