One of the hallmarks of a good and experienced Java developer is a broad understanding of apis, including the JDK and third-party libraries. I spent a lot of time learning about apis, especially after reading Effective Java 3rd Edition, where Joshua Bloch suggested how to develop using existing apis instead of writing new code for common things.

In this article, I’ll share some of the most useful and important libraries and apis that Java developers should be familiar with. However, I did not include frameworks such as Spring and Hibernate because they are well-known and have specific capabilities.

In general, I have included useful libraries in my daily projects, including the Log4j logging library, the Jackson JSON parsing library, and unit testing apis such as JUnit and Mockito. If you need to use these jars in your project, include them in your project’s classpath or use Maven for dependency management.

When you use Maven for dependency management, it automatically downloads these libraries, including the ones they depend on, called transitively dependent.

For example, if you download the Spring Framework, it will also download all the other Jars on which Spring depends, such as Log4j.

You may not have noticed, but having the correct version of the JAR is a headache. If it is the wrong version of the JAR, then you will meet a ClassNotFoundException, NoClassDefFoundError or UnsupportedClassVersionError

20 useful open source libraries for Java programmers

This is a collection of useful third-party libraries that Java developers can use to accomplish many useful functions in their applications. To use these libraries, Java developers should be familiar with them, which is the focus of this article. If you find it useful, you can study the library and use it.

1. The logging library

Log libraries are very common because they are required in every project. They are the most important thing for a server-side application, because the logs are only placed where you can see what is going on with the application currently running. Although the JDK ships with its own logging library, there are better alternatives, such as Log4j, SLF4j, and LogBack.


Should Java developers be familiar with the pros and cons of logging libraries and know why SLF4j is better than plain Log4j

2. JSON parsing library

In today’s World of Web services and the Internet of Things, JSON has become the preferred protocol for transferring information from clients to servers. They have replaced XML as the best way to transfer information between independent platforms.

Unfortunately, the JDK doesn’t have a JSON library. However, there are many excellent third-party libraries that allow you to parse and create JSON messages, such as Jackson and Gson.

Java Web developers should be familiar with at least one of these libraries. If you want to learn more about Jackson and JSON, I suggest you check out Udemy’s course JSON with the Java API

3. Unit test library

Unit testing is the single most important thing that separates the average developer from the best. Programmers often have a reason not to write unit tests, but the most common excuse for avoiding writing unit tests is a lack of experience and knowledge of common unit test libraries, including JUnit, Mockito, and PowerMock.


One of my goals for 2018 is to improve my knowledge of unit testing and integration testing libraries, such as JUnit 5, Cucumber, Robot framework and others.

I also registered JUnit and Mockito Crash Course in Udemy. Even if you know the basics of JUnit and unit testing, you may want to update and advance your knowledge.

4. Common libraries

Java developers can use several good generic third-party libraries, such as Apache Commons and Google Guava. I always include these libraries in my projects because they simplify a lot of functionality.

As Joshua Bloch points out in Effective Java, there is no point in reinventing the wheel. We should prefer to use proven libraries rather than implement them ourselves from time to time.


Familiarity with the Google Guava and Apache Commons libraries is a good thing for Java developers.

5. HTTP library

One thing I don’t like about the JDK is their lack of HTTP support. While you can use classes in the Java.NET package to establish HTTP connections, using open source third-party libraries such as Apache HttpClient and HttpCore is not easy or seamless to combine.

While JDK 9 brings HTTP 2.0 support and better HTTP support, I strongly recommend that all Java developers become familiar with the popular HTTP client libraries, including HttpClient and HttpCore.

You can also check out the article <u>What’s New in Java 9-modules and More</u> to learn More about JDK 9 support for HTTP 2.


XML parsing library

There are many XML parsing libraries, including Xerces, JAXB, JAXP, Dom4j, and Xstream. Xerces2 is the next high performance version of Apache Xerces, a fully compatible XML parser. This new version of Xerces introduces the Xerces Native Interface (XNI), a complete framework for building very modular and easy to program parser components and configurations.


image

The Apache Xerces2 parser is a reference implementation of XNI, but other parser components, configurations, and parsers can be written using the Xerces Native Interface. Dom4j is another flexible XML framework for Java applications. If you want to learn more about XML parsing in Java, you are advised to check out the Java Web Services and XML online course on Udemy.

7. Excel library

Believe it or not – all real-world applications must interact with Microsoft Office in some form. Many applications need to provide the ability to export data in Excel, and if you must do the same from a Java application, you need the Apache POI API.


This is a very rich library that allows you to read and write XLS files from Java programs. You can see the link (http://www.java67.com/2014/09/how-to-read-write-xlsx-file-in-java-apache-poi-example.html), To get a working example of reading Excel files in a core Java application.

Bytecode libraries

If you’re writing a framework that generates code or interacts with bytecode, you need a bytecode library.

They allow you to read and modify the bytecode generated by your application. Some of the most popular bytecode libraries in the Java world are Javassist and Cglib Nodep.


Javassist (Java Programming Assistant) makes Java bytecode manipulation very simple. It is a class library for editing bytecode in Java. ASM is another useful bytecode editing library. If you are not familiar with bytecodes, I recommend you check out Introduction to Java Programmers for more information about it.

9. Database connection pool library

If you are interacting with a database from a Java application but not using the database connection pool library, you will lose something.

Because creating a database connection at run time takes time and slows request processing, it is always recommended to use a database connection library. Some popular ones are Commons Pools and DBCP.

In a Web application, its Web server typically provides these capabilities, but in a core Java application, you need to include these connection pool libraries in the classpath to use the database connection pool.

If you want to learn more about JDBC and connection pooling in Web applications, I recommend you check out the JSP, Servlet, and JDBC for Beginners course in Udemy.

10. Messaging library

Like logging and database connections, messaging is a common feature of many real-world Java applications.

Java provides JMS, Java Messaging Service is not JDK. For this component, you need to include a separate component jms.jar.

Similarly, if you are using a third-party messaging protocol (such as Tibco RV), you need to place the third-party JAR TibrV.jar in the application classpath.


11. PDF library

Similar to Microsoft Excel, PDF libraries are another ubiquitous format. If you need to support PDF functionality in your application, such as exporting data to PDF files, you can use iText and Apache FOP libraries.

Both offer useful PDF-related functionality, but iText is richer and better. See here for more information about iText.




12. Date and time library

Prior to Java 8, the JDK’s data and time libraries were flawed because they were not thread-safe, immutable, and error-prone. Many Java developers rely on JodaTime for their date and time requirements.

Starting with JDK 8, there’s no reason to use Joda because you get all the functionality in JDK 8’s new date and time API, but if you’re using older Java versions, JodaTime is a library worth learning about.

If you want to learn more about the new date and time API, I suggest you check out the What’s New in Java 8 course on Udemy. It provides an excellent overview of all the important features of Java 8, including the date and time API.


13. The Collection library

Although the JDK has a rich collection library, there are third-party libraries that offer more options, such as The Apache Commons collection, Goldman Sachs Collection, Google Collection, and Trove.

The Trove library is particularly useful because it provides Java with high-speed general and raw collections.


FastUtil is another similar API. It extends the Java Collections framework by providing specific types of mappings, collections, lists, and priority queues, with small memory footprint, fast access, and inserts; It also provides large (64-bit) arrays, sets, and lists, as well as quick and useful I/O classes for binary and text files.

14.Email API

Both Javax. mail and Apache Commons Email provide an API for sending E-mail from Java. It builds on the JavaMail API and aims to simplify it.


15. HTML parsing library

Like JSON and XML, HMTL is another common format that many of us have to deal with. Thankfully, we have JSoup, which greatly simplifies the process of using HTML in Java applications.

Not only can you use JSoup to parse HTML, you can also create HTML documents



It provides a very convenient API for extracting and manipulating data, using DOM, CSS, and jquery-like methods. JSoup implements the WHATWG HTML5 specification and parses HTML into the same DOM, just like modern browsers.

16. Cryptographic library

The Apache Commons Codec package contains simple encoders and decoders in a variety of formats, such as Base64 and Hexadecimal.

In addition to these widely used encoders and decoders, the codec package also maintains a set of speech coding utilities.


17. Embedded SQL Database library

I really like in-memory databases like H2 that you can embed in your Java applications. They are great for testing SQL scripts and running unit tests that require a database. However, H2 is not the only DB, and you can also choose Apache Derby and HSQL.


18. JDBC troubleshooting library

There are some good JDBC extension libraries that make debugging easier, such as P6spy.

This is a library that intercepts and records database data seamlessly without code changes to the application. You can use them to record SQL queries and their timing.

For example, if you use PreparedStatment and CallableStatement in your code, these libraries can record the parameters of a full call and the time it takes to execute it.



If you want to learn more about JDBC, look at JDBC for Beginners.

19. Serialization library

Google Protocol Buffers is a way to encode structured data in an efficient and extensible format. It is a richer and better alternative to Java serialization. I highly recommend that experienced Java developers learn Google Protobuf. You can check out this article to learn more about Google protocol buffers.


20. The network library

Some useful network libraries are Netty and Apache MINA. If you are writing applications that need to perform low-level network tasks, consider using these libraries. If you want to learn more about Java Network Programming, see < U >Java Network Programming – TCP/IP Socket Programming</ U >.


**** These are the **** library **** that every Java developer should use for ****. The Java world is vast, and you’ll find countless libraries to do different things with.

If you want to do anything with Java, chances are you’ll find a library for how to do it. As always, Google is your best friend for finding useful Java libraries, but you can also check out Maven’s central repository to find some useful libraries for the task at hand.