Java ecosystem is huge and consists of countless libraries in the wild, including core java libraries as well as third party libraries. Every Java library tries to solve one or the other common java programming tasks and helps in effective and efficient programming.
Some of the most used core libraries include names like java.lang, java.util, java.io, java.sql, java.net whereas popular third party libraries include names like Junit, SLF4J, Google Guava, XStream, JSoup, Gson, Joda Time and the list is very long.
Which Java Library Do you need?
Every popular and most used library may not always be the right fit for your project. However, there are many tasks like unit testing, logging, serialization, coding standards enforcement etc., that are common across almost all projects, and for that reason popular libraries in these areas are probably the ones that you need too.
The key features JUnit include a clean GUI which allows effortless writing and testing of source code and helps developers complete tasks faster.
JUnit allows tests to continuously run, and supports concurrent running of multiple tests, with instant test results, with a test progress bar that keeps track of the progress. When the tests run smoothly, they remain green and when any failure occurs, the bar shows red.
Furthermore, JUnit provides the option to build test suites incrementally so that the overall progress can be measured correctly and side effects can be detected.
Unit testing being an inherent part of every development project, and JUnit’s simplicity and the speed of running tests make it stand tall compared to other unit testing libraries and frameworks out there in the wild.
Check out further details here at – JUnit Java Library.
SLF4J or Simple Logging Facade for Java and provides an abstraction for different frameworks which allows developers to plug in any framework at the time of deployment. The power of SLF4J lies in the simple logging API, based on façade pattern, and separates client API from the logging backend.
The backend is s found out by adding required binding to the classpath. Since client API and backend is totally de-coupled, it makes it an absolute breeze to integrate any framework or existing piece of code.
The credit of creating this useful facility goes to Ceki Gülcü. You can download SLF4J here at – SLF4J Download Link.
You might also like - Best Java Frameworks.
3. Google Guava
Google Guava is another popular set of core libraries in the world of Java programming, developed by Google and available as open source. The libraries included in the Google Guava project are used for developing/upgrading java based products at Google, on daily basis.
Libraries in Google Guava package are more or less like enhancements to the core library counterparts and makes programming more efficient and effective. Guava includes an in-memory cache, immutable collections, functional types, a graph library, and API utilities useful for, I/O, hashing, concurrency, primitives, String processing, reflection and many more.
Check out more about Google Guava here at - Core Java Libraries - Google Guava .
When it comes to serializing objects to and from XML, the XStream library is developer's trusted choice. This library lets developers easily serialize objects into XML and back.
Reflection is the key here and is used to identify the structure of the object graph to serialize at run time. No modifications are required to the objects. Any internal field can be serialized using XStream.
Talking about the features of XStream - Most objects can be serialized irrespective of providing the specific mapping, provides high performance and low memory footprint, suitable for large object graphs and systems with a higher throughput, no duplicity of information, customizable conversion strategies, a secure framework, detailed diagnostics in the case of an exception and much more.
The wide range of uses such as transport, configuration, persistence and unit tests makes it a popular Java library among the community of java developers.
You can download it here at: Xstream – Objects to XML.
Log4j is a library from Apache and is useful as a logging utility. This tool was initially developed by Ceki Gülcü. But now, Apache Software Foundation have taken up this project.
Log4j happens to be the most reliable library in its area of application, can be extended to support custom components configuration. The configuration syntax is real easy with support available for XML, YAML and JSON.
Log4J provides support to multiple APIs and can be used whit applications using different versions of Log4j or SLF4J. Another interesting feature is that it provides support for user-defined message objects. Above all, the speed with which it works is quite impressive.
You can download it here at - Download Log4J.
iText is a Java open source library used for the creation and manipulation of PDF files in Java. This library was initiated by a team including Bruno Lowagie and Paulo Soares.
While the previous iText versions had many limitations, the recent one includes many new features like option to create pdf, convert documents from XML, HTML, CSS or databases to PDF. The PDFs made follow the worldwide standards. It also allows to add interactivity in the PDFs and add digital signatures. You can copy, merge documents, import, change the structure and add watermark or barcode to PDFs.
Know more about iText here at – iText PDF library for Java
jsoup is a useful Java library that to work with and for parsing HTML. Jsoup provides a useful API that helps to extract data. The specification implemented in jsoup is WHATWG HTML5. As the latest browsers do, jsoup parses HTML into the DOM.
It allows or parse HTML from any URL or file, for example, you ca fetch the homepage of http://noeticforce.com, parse it, and fetch all H2 titles into list of elements.
Its uses include cleaning up and manipulation of HTML elements and attributes to retrieve user submitted data and filtering away XSS attack attributes, and there is much more that you can do with jsoup.
Download jsoup here at - download Jsoup.
Gson is another library from the house of Google and makes it an absolute breeze to convert Java Objects into equivalent JSON representation.
While there are some open-source projects that allow converting Java objects to JSON, they require you to place the Java annotations in the classes you have used. Obviously, you cannot do this if you cant access the source code, furthermore, most of the open source options do not support Java Generics. Gson takes care of these issues.
It provides simple toJson() and fromJson() methods that can be used to convert Java objects to JSON. Gson library allows the conversion of un-modifiable objects to JSON and back. As mentioned above, it provides great support for Java Generics and allows the custom representation of objects.
Here is the download link for Java Gson library - Download Gson.
9. Apache PDF box
Apache PDFBox is yet another open source library useful for manipulation of PDF files. This project was started by Ben Litchfield originally but picked up by Apache at a later stage.
The key features of PDFBox that makes it a super library includes features like PDF creation, splitting a single PDF to multiple PDFs files, merge, extract Unicode text for PDFs, fill a PDF form, validate PDFs against standards of PDF/A, Save a PDF as an image and digitally sign PDFs.
Check this out here at - Apache PDFBox
10. Joda Time
This is what i call a simple yet powerful library that saves lot of development time. Joda-Time is a Java library that acts as a good replacement for the date and time classes in Java.
Joda Time is easy to use and has field accessors like getYear() or getDayOfWeek() to get dates directly that makes it an absolute breeze to get details around date and time.
Joda Time also provides functionality for calculation of date and time and supports almost all date formats you would need, and that for sure is difficult to replicate with the plain JDK functions.
You can download Joda Time here at: Joda Time – Data Time Libray for Java
Apart from the 10 libraries covered above, there are many other general purpose as well as domain specific java libraries that are used heavily in small as well as large scale projects. Some of these libraries are as listed below –
Ok HTTP – A perfect library for efficiently exchanging data between modern applications over HTTP protocol. Okhttp recovers the connection problems during breaking network, switches the IP addresses in case of failure in a multiple IP based service. A useful feature of okhttp is the auto connection with modern TLS (SNI, ALPN) and falling back to TLS 1.0 in case of failures.
Check out this library here at - OK HTTP library for Java
Quartz – This one is another general purpose and useful java library that integrates with java applications of any scale and size. Quartz library can be used to create hundreds, thousands or more of jobs, you can scale as per the application needs. Quartz has power features like JTA transactions and clustering for enterprise grade applications support.
Read more here at: Quartz-Scheduler
Java is vast and you can easily find a ready to use library for anything and everything that you plan to do, just do a thorough research to figure out what is available and fitment to your project. Development from scratch is always an option, but why build when you get something that is ready to use, proven and is free to use.
Do share your experience with Java libraries, with our readers, via comments. Cheers!