Most useful Java libraries every Java developer should know

Java libraries aids in the development of our application. In fact JDK itself is a collection of libraries which is nothing but jar files. In this post we will discuss some of the useful Java libraries that are not part of JDK.

List of useful Java libraries

Each of the below library can be used based on the project requirement.

Apache Commons

Apache commons package contains several useful classes that can make our development easier. For example it contains a class called BeanUtils that can be used to clone a bean, copy properties of one bean to another bean etc. Let us see an example program using this class.

Some other useful classes in the package,

  • ListUtils
  • MapUtils
  • DateTimeConverter

and many more. The jar can be downloaded here – apache-commons.jar. The jar has a dependency on slf4j-api which can be downloaded here – http://www.slf4j.org/download.html.

Apache Commons Lang

Commons Lang is another package under the Apache commons project. It provides a host of helper utilities for the java.lang API, notably String manipulation methods, basic numerical methods, object reflection, concurrency, creation and serialization and System properties.

Additionally it contains basic enhancements to java.util.Date and a series of utilities dedicated to help with building methods, such as hashCode, toString and equals.

Here is a simple program showing usage of classes in lang package.

Some other useful classes in the package,

  • ArrayUtils
  • DateFormatUtils

The jar can be downloaded here – apache-commons-lang.jar.

Read my post on Useful utility classes in Apache Commons lang.

Apache Commons IO

Commons IO is a library of utilities to assist with developing IO functionality. Let see an example program using this library.

Download the jar – commons-io.

GSON

GSON, developed by Google, is used to convert Java objects to / from JSON. To know more about this library read my post – GSON Java.

Docx4j

docx4j is an open source Java library for creating and manipulating Microsoft Open XML (Word docx, Powerpoint pptx, and Excel xlsx) files.

It is similar to Microsoft’s OpenXML SDK, but for Java. docx4j uses JAXB to create the in-memory object representation. With docx4j you can create, edit word documents, add  header, footer etc.

Let us create a simple program to create a word document and add a paragraph.

Download docx4j.

DOM4J Parser

DOM4J is an open source, java based library for manipulation of XML, XSLT and XPath. It is easy to parse an XML document with dom4j.

A simple example to parse xml document.

Here is the content of the xml document used.

Download the jar here – dom4j.

SLF4J

Logging is important for Java applications, especially server side applications. Log plays a major role in debugging any issue. The Simple Logging Facade for Java is a popular logging library.  It provides an abstraction for various logging frameworks, such as java.util.logging, logback and log4j. We can plug in the desired logging framework at deployment time.

Here is a sample program.

SLF4J user manual –http://www.slf4j.org/manual.html

Download – http://www.slf4j.org/download.html

Hope you find the post useful. If you have any comments / suggestions, let us interact in the comments section.

The following two tabs change content below.
Working as a Java developer since 2010. Passionate about programming in Java. I am a part time blogger.

Add Comment

Required fields are marked *. Your email address will not be published.