Common Java Development Toolkit

Source: Internet
Author: User
Tags serialization http 2 java web google guava log4j

One of the most experienced Java developer features is being adept at using existing wheels to build cars. Joshua Bloch, author of effective Java, once said: "It is recommended to use the existing API to develop, rather than reinvent the wheel." In this article, I'll share some of the most useful and necessary libraries and APIs that Java developers should be familiar with. By the way, the framework is not included here, such as spring and hibernate because they are very famous and have specific functions.

This paper summarizes the common library of 20 aspects, such as log, JSON parsing, single test, XML parsing, byte code processing, database connection pool, collection class, mail, encryption, Embedded SQL database, JDBC fault diagnosis and serialization. are often used in your daily development, it doesn't matter now, but you need to know that there is an article for you to refer to.

Don't know it's not scary, scary is you don't know you don't know.

First, log related class library

Log libraries are common because you need them in every project. Print logs are the most important thing in server-side applications, because logs are the only way you know what's going on with your program. Although the JDK comes with its own log library, there are a number of better options available, such as log4j, SLF4J, and Logback.

Java developers should be familiar with the pros and cons of logging and understand why SLF4J is better than log4j.

Second, JSON parsing library

In today's world of Web services and the Internet of Things (IoT), JSON has replaced XML as the preferred protocol for transmitting information from the client to the server. Have a good news and a bad news. The bad news is that the JDK does not provide a JSON library. The good news is that there are many good third-party libraries that can be used to parse and create JSON messages, such as Jackson and Gson

A Java web developer should be familiar with at least one of the two libraries, Jackson and Gson.

Three, Unit Test library

The use of unit testing techniques is an important indicator of distinguishing between a general developer and a good developer. Programmers often have various excuses not to write unit tests, but the most common excuse is lack of experience and knowledge. Common single-Test frames are junit,mockito and powermock.

Iv. General Class Library

There are several good third-party universal libraries available to Java developers, such as Apache Commons and Google guava. I often use these generic libraries in my code because they have been practiced by countless developers and are best in terms of usability and performance.

Five, Http Library

I'm not a big fan of the JDK, including their lack of support for HTTP. While you can use the Java.net package class, this is a lot more cumbersome than using open source libraries like Apache HttpClient and Httpcore directly.

Although JDK 9 will start with HTTP 2.0, it also optimizes HTTP support, but I strongly recommend that all Java developers familiarize themselves with the popular HTTP handling class libraries such as HttpClient and Httpcore http.

Vi. XML Parsing Library

There are many types of XML parsing libraries, such as Xerces, JAXB, JAXP, dom4j, XStream and so on. Xerces2 is the next generation of high-performance, fully-compatible XML parsing tools. Xerces2 defines the Xerces Native Interface (XNI) specification and provides a complete, compliant implementation of the XNI specification. The parser is completely redesigned and implemented, simpler and more modular.

VII. Excel read-write library

Many applications need to provide the ability to export data to Excel, and if you want to do the same Java application then you need Apache POI API.

This is a very rich class library where you can read and write XLS files from Java programs.

Eight, byte code library

If you are writing a framework or class library. There are a number of popular bytecode libraries such as Javassist and Cglib NODEP available for you to choose from and they allow you to read and modify the bytecode generated by the application.

Javassist makes Java bytecode operations very simple. It is a class library that is born to edit Java bytecode. ASM is another useful bytecode-editing library.

Ix. Database Connection Pool Library

If your Java application does not interact with the database using the database connection pool, then you are wrong. Because creating a database connection at run time is time-consuming and slows down your program. So wall splitting is recommended, and there are some easy-to-use connection pools to choose from, such as Commons pool and DBCP.

In Web applications, these features are typically provided by Web servers. However, in a Java project, you need to import the database connection pool's class library into your app.

Ten, Message Delivery library

Like logs and database connection pools, messaging is a must for many real-world Java projects. Java provides the JMS Java messaging Service, but this is not part of the JDK, you need to introduce Jms.jar separately. Similarly, if you are ready to use a third-party messaging protocol, TIBCO RV is a good choice.

Xi. PDF Processing Library

In addition to Excel and Word,pdf is also a common file format. If your application supports file processing in PDF format, you can use the Itext and Apache FOP class libraries. Both provide a very useful PDF processing capability.

12. Date and Time Library

Before Java, the JDK's date and time library has been criticized, such as its non-thread-safe, immutable, error prone, and so on. Many developers will choose a better Jodatime class library.

But after Java8 is launched, we can completely abandon Jodatime because Java 8 provides all of its features. However, if your code is running in a lower version of the JDK, then Jodatime is still worth using.

13. Collection Class Library

Although the JDK has a rich collection class, there are a number of third-party class libraries that can provide more and better functionality. such as Apache Commons collections, Goldman Sachs collections, Google collections and trove. Trove is particularly useful because it provides a faster version of all standard collections classes and the ability to manipulate collections classes directly on primitives (primitive), such as maps that contain int keys or values.

Fastutil is another similar API that inherits the Java Collection Framework and provides several specific types of containers, including map maps, set sets, list lists, priority queues (prority queue), Implements the standard interface for the Java.util package (which also provides a bidirectional iterator that the standard class does not have), and also provides a large (64-bit) array, set, list, and fast, useful I/O operations class for binary or text files.

14. Mail API

Javax.mail and Apache Commons email provide an API for sending mail. They are based on the JavaMail API and provide simplified usage.

XV, HTML Parsing library

Like XML and JSON, HTML is another transport format that we might be dealing with. Thankfully, we have jsoup that can greatly simplify the use of HTML for Java applications. Not only can you use Jsoup to parse HTML, but you can also create HTML documents.

16. Encryption Library

The Apache Commons family of Commons codec provides some common codec implementations, such as Base64, Hex, md5,phonetic and URLs, and so on.

17. Embedded SQL Database Library

I really like the memory database like H2, he can embed into your Java application. When you run a single test, if you need a database to validate your SQL, he's a good choice. Incidentally, H2 is not the only embedded db, you also have Apache Derby and Hsql to choose from.

18. JDBC Fault Diagnosis Library

The presence of a good JDBC extension library makes debugging easy, such as p6spy, a dynamic monitoring framework for database access operations that allows database data to be captured and manipulated seamlessly without having to make any modifications to the existing application's code. The P6spy bundle includes P6log, an application that can log all JDBC transactions for any Java application. When the configuration is complete, data access performance can be monitored.

19. Serialization Library

Google Protocol Buffer is a lightweight and efficient structured data storage format that can be used for structured data serialization, or serializing. It is ideal for data storage or RPC data interchange formats. It can be used in the communication protocol, data storage and other fields of the language-independent, platform-independent, extensible serialization structure data format. The API is currently available in three languages of C + +, Java, and Python.

20. Network Library

Some useful network libraries are mainly Netty and Apache MINA. If you are writing an application that you need to do for the underlying network tasks, you can consider using these libraries.

This is a very useful library that every Java developer should be familiar with. The Java ecosystem is very large and you will find that there are many different classes of libraries that can do different things. Every thing you think of, there may be a library to do.

You have to believe that the problem you have encountered is certainly more than you have ever encountered.

Believe that there may be many people who are more diligent than you.

To believe that you use or not, the wheel is right there.

believe that using these libraries, you and your code will get better.

Common Java Development Toolkit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.