Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the Java class library and API that programmers must understand?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what Java class libraries and APIs programmers must understand". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn together "what Java class libraries and APIs programmers must understand"!

I. Log-related class libraries

Log repositories are common because you need them for every project. Printing logs is the most important thing in server-side applications because logs are the only way you know what's happening to your program. Although JDK comes with its own log library, there are many 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 primary protocol for transferring information from client to server. There is good news and bad news. The bad news is that JDK does not provide a JSON library. The good news is that there are many excellent 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 Jackson and Gson libraries.

III. Unit Test Library

The use of unit testing techniques is an important indicator that distinguishes an average developer from a good developer. Programmers often have various excuses for not writing unit tests, but the most common excuse is lack of experience and knowledge. Common single test frameworks are JUnit , Mockito and PowerMock.

IV. General class library

There are several good third-party common libraries available for Java developers, such as Apache Commons and Google Guava. I will often use these generic libraries in my code, because these libraries have been practiced by countless developers, both in terms of utility and performance.

V. Http library

One of the main reasons I don't like JDK very much is their lack of HTTP support. While it is possible to use java.net package classes, this is much more cumbersome than using open source libraries like Apache HttpClient and HttpCore directly.

Although JDK 9 will start HTTP 2.0 and optimize HTTP support, I strongly recommend that all Java developers familiarize themselves with popular HTTP handling libraries such as HttpClient and HttpCore HTTP.

VI. XML Parsing Library

There are many XML parsing libraries on the market, such as Xerces , JAXB , JAXP , Dom4j , Xstream, etc. 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, standards-compliant implementation of the XNI specification. The parser is completely redesigned and implemented to be simpler and 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 the Apache POI API.

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

VIII. Byte code library

If you are writing a framework or library. There are popular bytecode libraries like javassist and Cglib Nodep to choose from that allow you to read and modify the bytecode generated by your application.

Javassist makes Java bytecode manipulation very simple. It is a library for editing Java bytecode. ASM is another useful bytecode editing library.

IX. Database Connection Pool Library

If your Java application interacts with a database other than using a database connection pool library, then you are dead wrong. Because creating database connections at runtime is time-consuming and slows down your application. Therefore, it is recommended to use some useful connection pools to choose from, such as Commons Pool and DBCP.

In web applications, web servers typically provide these functions. But in java projects, you need to import the library of database connection pool into the application.

X. Message Passing Library

Like logging and database connection pooling, messaging is a must for many real-world Java projects. Java provides JMS Java Message Service, but this is not part of JDK, you need to introduce jms.jar separately. Similarly, Tibco RV is a good choice if you are prepared to use a third-party messaging protocol.

XI. PDF Processing Library

In addition to Excel and Word, PDF is also a commonly used file format. If your application supports PDF file processing, you can use iText and Apache FOP libraries. Both offer very useful PDF processing capabilities.

XII. Date and Time Library

Prior to Java, JDK's date and time library had been criticized for being thread-safe, immutable, and error-prone. Many developers will choose the JodaTime class library, which is better to use.

But with Java 8, we can give up JodaTime altogether, because Java 8 offers all its features. However, if your code is running in an earlier version of JDK, JodaTime is worth using.

XIII. Collection class library

While JDK has a rich collection of classes, there are many third-party libraries that provide more and better functionality. 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 as well as functionality of Collections classes that can operate directly on primitives (e.g., maps containing int keys or values, etc.).

FastUtil is another similar API that inherits from the Java Collection Framework and provides several specific types of containers, including map, collection set, list, priority queue, implements the standard interface of the java.util package (also provides bidirectional iterators that standard classes do not), and also provides very large (64-bit) arrays, sets, lists, and fast, useful binary or text file I/O classes.

XIV. Mail API

javax.mail and Apache Commons Email provide APIs for sending emails. They build on the JavaMail API and provide simplified usage.

XV. HTML Parsing Library

Like XML and JSON, HTML is another transport format we might have to deal with. Thankfully, we have jsoup that greatly simplifies Java applications using HTML. You can use JSoup not only to parse HTML but also to create HTML documents.

XVI. Encryption Library

Apache Commons Codec provides common codec implementations such as Base64, Hex, MD5,Phonetic and URLs.

XVII. Embedded SQL Database Library

I really like in-memory databases like H2, which can be embedded into your Java applications. If you need a database to validate your SQL, it's a good choice when you're running tests. By the way,H2 isn't the only embedded DB, you still have Apache Derby and HSQL to choose from.

XVIII. JDBC Fault Diagnosis Library

Debugging is made easy by the presence of good JDBC extensions, such as P6spy, a dynamic monitoring framework for database access operations that allows database data to be seamlessly intercepted and manipulated without any modifications to the code of existing applications. The P6Spy distribution includes P6Log, an application that logs all JDBC transactions for any Java application. Data access performance can be monitored when configured and used.

XIX. Serialization Library

Google Protocol Buffer is a lightweight and efficient structured data storage format that can be used for structured data serialization, or serialization. It is well suited for data storage or RPC data exchange formats. It can be used in communication protocol, data storage and other fields, language-independent, platform-independent, extensible serialized structure data format. API is currently available in C++, Java and Python.

XX. Network Library

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

These are all libraries that every Java developer should be familiar with, and useful for. The Java ecosystem is huge, and you'll find that there are many different libraries that can do different things. For everything you think of, there's probably a library that can do it.

Thank you for reading, the above is "programmers must understand Java class library and API is what" content, after the study of this article, I believe that we must understand the Java class library and API is what this problem has a deeper understanding, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report