Overview of Google's Java Library Guava
Overview
The Java development language has many open-source libraries, and Google also provides an open-source library called “Guava.”
Here, we will look at the useful features of Guava.
What Is Google Guava?
Google Guava is an open-source Java library developed by Google on GitHub. The GitHub project page is here.
(It was first developed on Google Code, but the development location was later moved to GitHub.)
Google Guava provides features such as strings, collections, caches, primitive operations, file operations, and annotations, and it can be used with Java 1.8 or later. Some features overlap with Apache Commons, but it is useful to understand Google Guava’s features and choose the right tool for each case.
Applying It
This section explains how to apply it to a Java project.
If you want to download the Google Guava jar directly, download the zip or tar.gz file from the GitHub Release page.
If your project uses Apache Maven, add the following dependency to pom.xml.
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
<!-- or, for Android: -->
<version>31.1-android</version>
</dependency>
If you use Gradle, specify the following.
dependencies {
// Pick one:
// 1. Use Guava in your implementation only:
implementation("com.google.guava:guava:31.1-jre")
// 2. Use Guava types in your public API:
api("com.google.guava:guava:31.1-jre")
// 3. Android - Use Guava in your implementation only:
implementation("com.google.guava:guava:31.1-android")
// 4. Android - Use Guava types in your public API:
api("com.google.guava:guava:31.1-android")
}
Until version 21.0 in January 2017, there was only one version, but after that a separate Android version was released.