There are hundreds of Java libraries available today that cover every type of programming problem a Java developer is likely to come across. This article will take a look at Java libraries (core java and third party) every Java developer should know about before they write their first piece of code. Unfortunately, you will not find any of below mentioned third party libraries in java books since they are mostly project and requirements specific.
But before we begin with the list, let’s take a look at what a Java library does:
Understanding Java Library
According to Wiki:
The Java Class Library (JCL) is a set of dynamically loadable libraries that Java applications can call at run time.
The standard Java library consists of a number of packages. Each package, in turn, consists of a number of classes (that provide similar functionality).
Most Widely Used Third-Party Libraries
Below are some of the best and heavily used third-party open source libraries in java. These libraries demonstrate the real power of Java and make Java one of the most popular language on the planet.
Popular Unit Testing Libraries
Here are some popular Java unit testing libraries and their official websites:
- JUnit: A popular testing framework for Java that provides a way to write and run unit tests.
- TestNG: A testing framework for Java that supports testing at the unit, functional, and integration level.
- Mockito: A mocking framework for Java that allows developers to create and configure mock objects for unit testing.
- PowerMock: An extension to Mockito and EasyMock that enables the mocking of static methods, constructors, and other difficult-to-test code.
- AssertJ: A fluent assertion library for Java that provides an easy-to-use API for writing assertions in tests.
- Hamcrest: A framework for writing matcher objects in unit tests.
- EasyMock: A mocking framework for Java that simplifies the creation of mock objects for unit testing.
- Spock: A testing and specification framework for Java and Groovy that emphasizes concise and readable test code.
- Cucumber: A tool for behavior-driven development (BDD) that allows developers to write executable specifications in plain text. Website:
- Arquillian: A testing platform that allows developers to test their applications in a real container or server environment.
These are just some of the many Java unit testing libraries available, and each has its own strengths and weaknesses depending on the specific needs of a project.
Popular Utility Libraries
Apache Commons Collections
This is a library that provides enhancements on core java collections. It provides additional collections and utility methods to manipulate collection objects easily and efficiently.
Google Guava
Google Guava is an open-source set of common libraries for Java. It is designed by Google and was previously known as Google Collections. It’s a useful source of miscellaneous utility functions and classes. It’s basically a core library for immutable collections, string manipulation, caching, primitives support, and easier I/O functions.
Apache DBCP – Database Connection Pooling Library
This is a powerful library that provides a feature of connection pooling to relational databases. This library has existed for a long time and has been used in many applications including application servers.
Apache IO – Input Output Utilities
Apache IO is a powerful library to do file and stream operations efficiently and quickly in Java.
Many utility methods from this library have been adopted in recent Java versions.
XML Manipulation Libraries
Apache Commons Digester For XML
The digester is an XML to Java mapping utility that has been heavily used in XML communication using java. Reading XML config files and data can be really easy for the digester.
JSoup
jSoup is a library that is used for parsing HTML files in Java. It can be used for web application unit testing and web scraping. Its “jQuery-like” and “regex” selector syntax is very easy to use for data extraction. jSoup is quite fast in retrieving the raw page content.
XML Parsers
JDOM
JDOM is a popular DOM parser library that is widely used in many Java applications for parsing XML.
DOM4J
Its a simple open-source library for the manipulation of XML, XSLT, and XPath.
XERCES
Yet another popular XML parser.
JSON Libraries
Gson
JSON parsing library by Google
Jackson
A high-performance JSON processor. Jackson is a multi-purpose Java library for processing JSON and XML data format. It’s a fast, lightweight, and user-friendly library for developers.
XStream
XStream is a simple library to serialize objects to XML and JSON
Popular Chart And Graph Libraries In Java
There are many good charting libraries in Java we have picked two of the most popular ones in this list.
JFreeChart
The JFreeChart is the easiest and most widely used graphical library for creating a wide variety of good looking charts. JFreeChart allows the users to generate a pie chart, bar chart, time-series chart, Gantt chart, histogram, X-Y charts, and various specific charts.
JasperReports
This is a full-fledged feature-rich library to create graphs and charts. This is also available with enterprise support.
Popular JDBC & Object Relational Mapping Frameworks in Java
ORM tools have been criticized for their weaknesses http://java.dzone.com/articles/martin-fowler-orm-hate however they are still very popular since they can help developers avoid writing queries for the most part of the project.
Hibernate
Hibernate ORM (object-relational mapping) is a Java library released this year in April that provides a framework to perform object-relational mapping and query databases using HQL (Hibernate Query Language) and SQL. Hibernate supports the mapping of Java classes to database tables. Hibernate is data-independent, i.e. the same code will work on all databases.
MyBatis
MyBatis (formerly iBatis) is another popular ORM tool after hibernate. This is still under active development and is used by many people.
JGraphT
jGraphT is another free Java library that provides mathematical graph-theory objects and algorithms basically with a focus on data structures. It supports various types of graphs like directed and undirected, multigraphs, pseudographs, unmodifiable graphs, and many more. It is a simple to use and efficient Java library.
FreeHEP
FreeHEP, an open-source Java library enables users to easily write Java code for applications that involve higher energy physics. Although the main focus of this library is high-energy physics, it does contain many APIs that are generic and suitable for non-physics applications.
The Lightweight Java Game Library (LWJGL)
This Java game library is platform-independent and offers access to OpenGL, OpenCL, and OpenAL. Apart from handling graphics and gaming sounds, it provides access to controllers such as Gamepads, Steering wheels, and Joysticks. If you are a Java developer, developing a game, give LJGL a try.
Java WordNet Library (JWNL)
JWNL is an API that allows Java applications to retrieve data from WordNet. JWNL allows developers to easily build NLP applications.
Java Text Categorizing Library (JTCL)
It is a Java implementation of libTextCat; a library for language guessing.
OpenNLP
Open NLP is a library from Apache used for processing natural language text. It is a collection of Java-based NLP tools for part-of-speech tagging, sentence-segmentation, tokenization, chunking, parsing, and entity extraction. It supports Maximum Entropy Model (MaxEnt); a popular machine learning model for natural language processing tasks.
Commons Math
Commons Math is another great library from Apache. It addresses the most common problems of mathematics and statistics that are not available in the Java programming language.
Logging Libraries
Log4j
The most popular and oldest logging library.
Logback
Logback is a logging framework that has some really useful features that are not supported by log4j.
SLF4J
Every Java programmer knows that logging is critical for any Java application, especially server-side application. Most of the programmers would be familiar with SLF4J as it is the most popular logging library. It provides Java API for various logging frameworks allowing users to plug in the desired logging framework at deployment time.
Document Manipulation
Apache POI
Apache POI is a powerful java API for Microsoft documents.
Docx4j
Docx4j is yet another document manipulation library for multiple types of document processing.
Application Layer Frameworks
Spring & Spring Boot
Spring is the most popular dependency injection framework. Spring Boot framework is very popular for microservices development.
Struts
Struts is one of the most widely used web frameworks on Java.
GWT Google Web Toolkit
GWT is a web user interface library that can render Javascript and HTML based UI using Java code.
Vaadin
Vaadin is a Java framework for web beautiful looking applications.
Grails
Grail is an open-source framework based on Groovy that support rapid application development.
Play Framework
Play framework is another powerful web application framework for Java and Scala developers.
Netty
Netty is an asynchronous event-driven network application framework for developing high-performance applications.
Akka
Akka is a powerful application framework for developing high-performance java tools.
These are the Java libraries all Java developers should make use of whenever required!
SWT
SWT is an open-source widget toolkit developed by the eclipse foundation. This is a really powerful library developed by IBM.
Apache Pivot
Pivot is an open-source platform for developing installable desktop UI applications in Java.
Most Widely Used Core Java Packages & Internal Libraries
These are the Java libraries that are bundled with JDK and used for almost any application developed in java.
Java.lang
The java.lang package contains the classes and interfaces that are fundamental to the core Java language. The most important classes of this package are Object, which is the root of class hierarchy, and Class, instances of which represent classes at run time. Java depends directly on these two classes, making it indispensable for all java programs. Other classes from this package include Boolean, Byte, Float, Math, Process, and many more.
Java.util
This library provides users with generic java utilities like collections framework, formatted printing and scanning, array manipulation utilities, event model, date and time facilities, internationalization, and miscellaneous utility classes. The classes and interfaces in java.util include Hashtable, Vector, Enumeration, StringTokenizer, EventObject, Locale, Calendar and TimeZone, and ResourceBundle.
Java.io
This library is very useful and contains the classes that handle fundamental input and output operations in Java. The I/O classes in this package can be grouped as follows:
- Classes for reading input from a stream of data.
- Classes for writing output to a stream of data.
- Classes that manipulate files on the local filesystem.
- Classes that handle object serialization.
Java.net
The package java.net contains classes and interfaces that provide a powerful infrastructure for networking in Java. The java.net package can be roughly divided into two sections: a low-level API and a high-level API. Low-level API has classes like InetAddress whereas high-level API has classes like URL, URI, URLConnection, and HttpURLConnection.
Java.net
The package java.net contains classes and interfaces that provide a powerful infrastructure for networking in Java. The java.net package can be roughly divided into two sections: a low-level API and a high-level API. Low-level API has classes like InetAddress whereas high-level API has classes like URL, URI, URLConnection, and HttpURLConnection.
Java.security
This package has several classes that allow users to encrypt a file using a user-provided key. It supports cryptography and digital signature.
Java.sql
It contains all the SQL related classes and interfaces. This package provides the API for accessing and processing data stored in a data source.
Java.swing
The UI library for developing desktop Java applications.
Article Updates
- Article updated on Match 2023. Added Most important unit testing libs. Fixed formatting and updated image. Restructured and move core libs at bottom.
- Article Updated on August 2021. Some HTTP links are updated to HTTPS. Updated broken links with latest URLs. Some minor text updates done. Content validated and updated for relevance in 2021.
- Updated in April 2019: Minor changes and updates to the introduction section. Images are updated to HTTPS.
Michael Georgiou is a dynamic business professional and entrepreneurial guru associated with Imaginovation – proven his success in creative strategy, online branding, project management, and communication projects in both the public and private sectors.