# How to Include Guava in a Maven Project: Complete Dependency Guide

> Easily include Guava in your Maven project by declaring the correct dependency. Learn to choose between -jre and -android versions for your build.

- Repository: [Google/guava](https://github.com/google/guava)
- Tags: how-to-guide
- Published: 2026-08-10

---

**To include Guava in a Maven project, declare a `<dependency>` with group ID `com.google.guava`, artifact ID `guava`, and select either the `-jre` or `-android` version suffix to match your target runtime environment.**

Guava is Google's core Java utilities library published to Maven Central. Whether you are building a server-side application or Android software, adding Guava to your [`pom.xml`](https://github.com/google/guava/blob/main/pom.xml) requires understanding the two available build flavors and their specific Maven coordinates as defined in the google/guava repository.

## Choosing the Right Guava Flavor (JRE vs Android)

Guava provides two distinct build flavors that determine API availability and Java version compatibility. Choosing the correct flavor when you add Guava to your Maven build prevents runtime errors and ensures access to the appropriate feature set.

- **JRE Flavor** (`-jre` suffix): Targets Java 8 and higher. This version contains the complete Guava API including classes that depend on newer Java language features. Use this for standard server-side or desktop applications.

- **Android Flavor** (`-android` suffix): Compatible with Android runtimes and older Java versions. This flavor excludes APIs that rely on Java 8+ language features unavailable on Android. Reference [`android/pom.xml`](https://github.com/google/guava/blob/main/android/pom.xml) in the repository for the exact build configuration.

According to the Guava README and build definitions, the version suffix determines which artifact variant Maven resolves.

## Adding the Maven Dependency

Add Guava to your Maven project by inserting a `<dependency>` block inside the `<dependencies>` section of your [`pom.xml`](https://github.com/google/guava/blob/main/pom.xml). Use the coordinates `com.google.guava:guava` with the appropriate version string.

**Standard JRE dependency:**

```xml
<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>33.6.0-jre</version>
</dependency>

```

**Android-compatible dependency:**

```xml
<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>33.6.0-android</version>
</dependency>

```

Replace `33.6.0` with the latest release version found in [`guava/pom.xml`](https://github.com/google/guava/blob/main/guava/pom.xml) or the project's release notes.

## Understanding Guava's Bill of Materials (BOM)

For multi-module Maven projects, Guava provides a Bill of Materials (BOM) to ensure consistent versioning across dependencies. The BOM is defined in [`guava-bom/pom.xml`](https://github.com/google/guava/blob/main/guava-bom/pom.xml) and allows you to import a managed set of Guava versions via `<dependencyManagement>`.

Using the BOM prevents version conflicts when multiple modules depend on Guava:

```xml
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava-bom</artifactId>
      <version>33.6.0-jre</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

<dependencies>
  <dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <!-- Version is inherited from BOM -->
  </dependency>
</dependencies>

```

## Complete Working Example

Below is a minimal, runnable Maven project structure demonstrating how to include Guava in a Maven project and use its `ImmutableList` class.

**[`pom.xml`](https://github.com/google/guava/blob/main/pom.xml):**

```xml
<project xmlns="http://maven.apache.org/POM/4.0.0" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
                             http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>guava-demo</artifactId>
  <version>1.0.0</version>

  <dependencies>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>33.6.0-jre</version>
    </dependency>
  </dependencies>
</project>

```

**[`src/main/java/com/example/App.java`](https://github.com/google/guava/blob/main/src/main/java/com/example/App.java):**

```java
package com.example;

import com.google.common.collect.ImmutableList;

public class App {
  public static void main(String[] args) {
    ImmutableList<String> items = ImmutableList.of("Guava", "in", "Maven");
    System.out.println(items);
  }
}

```

Running `mvn compile exec:java` confirms Guava is correctly resolved from Maven Central and available on the classpath.

## Summary

- Guava is available on Maven Central under `com.google.guava:guava` with two flavor suffixes: `-jre` for Java 8+ and `-android` for Android compatibility.
- The JRE flavor defined in [`guava/pom.xml`](https://github.com/google/guava/blob/main/guava/pom.xml) provides the complete API, while the Android flavor in [`android/pom.xml`](https://github.com/google/guava/blob/main/android/pom.xml) excludes Java 8-dependent features.
- Guava automatically pulls in `com.google.guava:failureaccess:1.0.3` as a transitive runtime dependency.
- Use [`guava-bom/pom.xml`](https://github.com/google/guava/blob/main/guava-bom/pom.xml) via `<dependencyManagement>` to enforce consistent Guava versions across multi-module projects.

## Frequently Asked Questions

### What is the difference between the JRE and Android flavors of Guava?

The **JRE flavor** requires JDK 1.8 or higher and includes all Guava APIs, including those using Java 8 language features like streams and lambdas. The **Android flavor** targets Android runtimes and excludes APIs that depend on Java 8 features unavailable on older Android versions. Both flavors share the same group ID and artifact ID but use different version suffixes (`-jre` vs `-android`).

### Does Guava have any transitive dependencies I need to worry about?

Guava has a runtime dependency on `com.google.guava:failureaccess:1.0.3`, which Maven automatically resolves and includes in your classpath. According to the Guava README, no additional manual dependency management is required for standard usage, though you should verify this in [`guava/pom.xml`](https://github.com/google/guava/blob/main/guava/pom.xml) when upgrading versions.

### How do I manage Guava versions across multiple Maven modules?

Import the Guava BOM (Bill of Materials) from [`guava-bom/pom.xml`](https://github.com/google/guava/blob/main/guava-bom/pom.xml) in your parent POM's `<dependencyManagement>` section using scope `import`. This locks all Guava artifacts to the same version across child modules without requiring explicit version tags in individual dependency declarations.

### Can I use Guava with Java versions older than Java 8?

No. Both Guava flavors require at least Java 8. The Android flavor maintains compatibility with Android runtimes but still requires Java 8 source compatibility. If you require support for Java 7 or earlier, you must use Guava version 23.0-android or earlier, though these versions are no longer maintained.