In this article, I will introduce the concept of libraries, how to use them, their various forms and present the most popular and most frequently used libraries.
Preface
Knowing from another article that Java language alone is not enough, this time we have to prepare for the multitude of tools, libraries, frameworks that are available for the Java language and which support the work of a Java programmer.
Nowadays, when a Java programmer writes application code, she uses other Java classes, which also use other Java classes. Dependencies are created between classes. More classes for a project are placed in libraries that can be used by other developers.
It's hard to find code that doesn't consist of other classes, unless it is Hello World!. Even within our own application we use several of our own classes, if this is not the case, we are probably violating the principle of Single Responsibility with SOLID.
If we have more than one class in the project, we create a file from such a project JAR, a library that will contain compiled and ready-made classes for use by other programmers. Most useful libraries can be downloaded from Maven Repository.
Differences between concepts
Before I present the list of libraries and frameworks, I will explain difference between these concepts. Both the library and the framework are added to the project as dependencies, by dependencies we mean a set of classes available in the form of a JAR file.
Library
Without going into technical details, a library is something we use, something we use in our project, it gives us a tool to solve a specific task, e.g. text operations.
Framework
It is something that provides a template that we fill out and that uses our classes, manages them and provides a whole set of tools to support our task, e.g. creates objects for us, displays a graphical user interface.
Tools
So far I haven't mentioned anything about tools, I have only presented libraries and frameworks. Tools supporting the work of a Java programmer are in most cases separate applications that have their own user interface (graphical, textual), commands and commands. These applications are installed separately or as plug-ins, e.g. for the browser, IntelliJ IDEA IDE. Tools to facilitate a developer's work:
– Postman,
– Web browser in developer mode,
– GitHub – remote git repository.
Examples
I have given some examples of programming tools above. Below I will show you some examples of libraries and frameworks.
Library
A library worth your attention is Lombok, which allows us to save time and effort in writing repetitive code for classes POJO, automatically generates e.g. constructors, get/set methods, toString() method for us. Libraries created by the foundation are very popular Apache, you can mention, among others, Apache Commons. The ModelMapper library is also useful, which facilitates the process of mapping one class to another class.
Framework
An example of a framework is JUnit which supports testing our code. This is the most popular framework for testing Java code, there are others such as Selenium, TestNG, Mockito. The most popular framework is Spring framework, the description of this framework goes beyond this article, please read the official documentation Spring Framework and information at Wikipedia.
How to choose a library or framework?
How to find and choose the right library or framework for us? After reading this article, you can clearly see that it is not easy to find your way in the maze of available libraries and frameworks. When I'm looking for a library, I'm actually looking for a solution to a problem, and the library appears "alongside" an example of a solution to a given problem. It is said that there is already a solution to a given problem in Java, and in most cases such a solution is generalized enough to be available in the form of a library or framework.
Dependencies
Finally, I will present a list of dependencies and libraries that we can add to the "starter" application based on Spring Framework. A simple web application (Spring MVC + Thymeleaf) with the option of data persistence (Spring Data JPA). Why am I writing about this? After adding the following 4 dependencies, we get about 90 libraries that these four added libraries use - a veritable ocean of dependencies!
spring-boot-starter-web spring-boot-starter-thymeleaf spring-boot-starter-data-jpa spring-boot-starter-test
Below are the previously mentioned dependencies for a simple application written using Spring Framework - Maven dependencies.
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies>

Below are the previously mentioned dependencies for a simple application written using Spring Framework - Gradle dependencies.
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation group: 'org.modelmapper', name: 'modelmapper', version: '2.3.5'
implementation group: 'org.projectlombok', name: 'lombok', version: '1.18.8'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation group: 'com.h2database', name: 'h2', version: '1.4.199'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
}
Below are the dependencies for the libraries I mentioned in the examples above – Gradle dependencies.
dependencies {
implementation group: 'org.modelmapper', name: 'modelmapper', version: '2.3.5'
implementation group: 'org.projectlombok', name: 'lombok', version: '1.18.8'
testImplementation group: 'com.h2database', name: 'h2', version: '1.4.199'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
}