YouTip LogoYouTip

Java Libs

Common Java Libraries |

\n\n

Java provides a rich set of libraries. Below are some of the most commonly used classes.

\n\n

1. Core Java Libraries

\n

The Java Standard Library provides a rich set of built-in libraries. Here are some commonly used core libraries:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
CategoryLibrary NameMain Function
Collection Frameworkjava.util.ArrayListDynamic array implementation
java.util.LinkedListDoubly linked list implementation
java.util.HashMapMap implemented with a hash table
java.util.VectorImplements a dynamic array
java.util.HashSetSet based on a hash table
java.util.ScannerCaptures user input
java.util.regex.PatternRegular expressions
java.util.regex.MacherRegular expressions
IO/NIOjava.io.FileFile and directory operations
java.nio.file.FilesUtility class for file operations
java.io.InputStreamBase class for byte streams
java.io.OutputStreamBase class for byte streams
Multithreadingjava.lang.ThreadThread operation class
java.util.concurrent.ExecutorServiceThread pool management
Date & Timejava.time.LocalDateDate handling
java.time.LocalDateTimeDate and time handling
java.time.ZonedDateTimeDate and time with timezone
java.util.DateCurrent date
java.text.SimpleDateFormatDate/time formatting
java.util.CalendarHandles date and time
java.util.GregorianCalendarImplements the Gregorian calendar
java.time.InstantRepresents an instantaneous point on the timeline
java.time.ChronoUnitStandard units for measuring time
java.time.PeriodRepresents a time interval between two dates
java.time.DurationRepresents a time-based duration (hours, minutes, seconds, nanoseconds)
Network Programmingjava.net.URLURL handling
java.net.SocketSocket programming
\n\n
\n\n

2. Common Third-Party Libraries

\n

Here are widely used third-party libraries in the Java ecosystem:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
CategoryLibrary NameMain FunctionOfficial Website
JSON ProcessingJacksonJSON serialization/deserializationhttps://github.com/FasterXML/jackson
GsonGoogle's JSON libraryhttps://github.com/google/gson
Unit TestingJUnitJava unit testing frameworkhttps://junit.org/junit5/
MockitoMock testing frameworkhttps://site.mockito.org/
LoggingLog4jLogging frameworkhttps://logging.apache.org/log4j/
SLF4JLogging facade frameworkhttps://www.slf4j.org/
Web DevelopmentSpring FrameworkEnterprise application frameworkhttps://spring.io/projects/spring-framework
Spring BootRapid application development frameworkhttps://spring.io/projects/spring-boot
DatabaseHibernateORM frameworkhttps://hibernate.org/
MyBatisSQL mapping frameworkhttps://mybatis.org/mybatis-3/
Build ToolsMavenProject build and dependency managementhttps://maven.apache.org/
GradleFlexible build toolhttps://gradle.org/
\n\n
\n\n

3. How to Choose the Right Library

\n\n

3.1 Evaluation Criteria

\n
    \n
  1. Functional Requirements: First, clarify what features the project needs
  2. \n
  3. Community Support: An active community means better support and documentation
  4. \n
  5. Performance: Requires special consideration for performance-sensitive applications
  6. \n
  7. Learning Curve: Consider the team's learning cost
  8. \n
  9. Maintenance Status: Check if the project is still actively maintained
  10. \n
\n\n

3.2 Version Selection Recommendations

\n
    \n
  • Prioritize LTS (Long-Term Support) versions
  • \n
  • Avoid using versions that have reached end-of-life
  • \n
  • New projects can consider newer stable versions
  • \n
\n\n
\n\n

4. Usage Examples

\n\n

4.1 Processing JSON with Jackson

\n\n

Example

\n
import com.fasterxml.jackson.databind.ObjectMapper;\n\npublic class JsonExample {\n\npublic static void main(String[] args){\n\n ObjectMapper mapper =new ObjectMapper();\n\ntry{\n\n// Object to JSON\n\nString json = mapper.writeValueAsString(new User("Zhang San", 25));\n\nSystem.out.println(json);\n\n// JSON To Object\n\n User user = mapper.readValue(json, User.class);\n\nSystem.out.println(user);\n\n}catch(Exception e){\n\n e.printStackTrace();\n\n}\n\n}\n\n}
\n\n

4.2 Unit Testing with JUnit

\n\n

Example

\n
import org.junit.jupiter.api.Test;\n\nimport static org.junit.jupiter.api.Assertions.*;\n\nclass CalculatorTest {\n\n @Test\n\nvoid testAdd(){\n\n Calculator calc =new Calculator();\n\n assertEquals(5, calc.add(2, 3));\n\n}\n\n}
← Java Linkedlist AddallJava Vector Tostring β†’