1# Guava: Google Core Libraries for Java 2 3[](https://github.com/google/guava/releases/latest) 4[](https://github.com/google/guava/actions) 5[](https://bestpractices.coreinfrastructure.org/projects/7197) 6 7 8 9Guava is a set of core Java libraries from Google that includes new collection 10types (such as multimap and multiset), immutable collections, a graph library, 11and utilities for concurrency, I/O, hashing, primitives, strings, and more! It 12is widely used on most Java projects within Google, and widely used by many 13other companies as well. 14 15 16 17Guava comes in two flavors: 18 19* The JRE flavor requires JDK 1.8 or higher. 20* If you need support for Android, use 21 [the Android flavor](https://github.com/google/guava/wiki/Android). You can 22 find the Android Guava source in the [`android` directory]. 23 24[`android` directory]: https://github.com/google/guava/tree/master/android 25 26## Adding Guava to your build 27 28Guava's Maven group ID is `com.google.guava`, and its artifact ID is `guava`. 29Guava provides two different "flavors": one for use on a (Java 8+) JRE and one 30for use on Android or by any library that wants to be compatible with Android. 31These flavors are specified in the Maven version field as either `33.3.0-jre` or 32`33.3.0-android`. For more about depending on Guava, see 33[using Guava in your build]. 34 35To add a dependency on Guava using Maven, use the following: 36 37```xml 38<dependency> 39 <groupId>com.google.guava</groupId> 40 <artifactId>guava</artifactId> 41 <version>33.3.0-jre</version> 42 <!-- or, for Android: --> 43 <version>33.3.0-android</version> 44</dependency> 45``` 46 47To add a dependency using Gradle: 48 49```gradle 50dependencies { 51 // Pick one: 52 53 // 1. Use Guava in your implementation only: 54 implementation("com.google.guava:guava:33.3.0-jre") 55 56 // 2. Use Guava types in your public API: 57 api("com.google.guava:guava:33.3.0-jre") 58 59 // 3. Android - Use Guava in your implementation only: 60 implementation("com.google.guava:guava:33.3.0-android") 61 62 // 4. Android - Use Guava types in your public API: 63 api("com.google.guava:guava:33.3.0-android") 64} 65``` 66 67For more information on when to use `api` and when to use `implementation`, 68consult the 69[Gradle documentation on API and implementation separation](https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_separation). 70 71## Snapshots and Documentation 72 73Snapshots of Guava built from the `master` branch are available through Maven 74using version `HEAD-jre-SNAPSHOT`, or `HEAD-android-SNAPSHOT` for the Android 75flavor. 76 77- Snapshot API Docs: [guava][guava-snapshot-api-docs] 78- Snapshot API Diffs: [guava][guava-snapshot-api-diffs] 79 80## Learn about Guava 81 82- Our users' guide, [Guava Explained] 83- [A nice collection](https://www.tfnico.com/presentations/google-guava) of 84 other helpful links 85 86## Links 87 88- [GitHub project](https://github.com/google/guava) 89- [Issue tracker: Report a defect or feature request](https://github.com/google/guava/issues/new) 90- [StackOverflow: Ask "how-to" and "why-didn't-it-work" questions](https://stackoverflow.com/questions/ask?tags=guava+java) 91- [guava-announce: Announcements of releases and upcoming significant changes](https://groups.google.com/group/guava-announce) 92- [guava-discuss: For open-ended questions and discussion](https://groups.google.com/group/guava-discuss) 93 94## IMPORTANT WARNINGS 95 961. APIs marked with the `@Beta` annotation at the class or method level are 97 subject to change. They can be modified in any way, or even removed, at any 98 time. If your code is a library itself (i.e., it is used on the CLASSPATH of 99 users outside your own control), you should not use beta APIs unless you 100 [repackage] them. **If your code is a library, we strongly recommend using 101 the [Guava Beta Checker] to ensure that you do not use any `@Beta` APIs!** 102 1032. APIs without `@Beta` will remain binary-compatible for the indefinite 104 future. (Previously, we sometimes removed such APIs after a deprecation 105 period. The last release to remove non-`@Beta` APIs was Guava 21.0.) Even 106 `@Deprecated` APIs will remain (again, unless they are `@Beta`). We have no 107 plans to start removing things again, but officially, we're leaving our 108 options open in case of surprises (like, say, a serious security problem). 109 1103. Guava has one dependency that is needed for linkage at runtime: 111 `com.google.guava:failureaccess:1.0.2`. It also has 112 [some annotation-only dependencies][guava-deps], which we discuss in more 113 detail at that link. 114 1154. Serialized forms of ALL objects are subject to change unless noted 116 otherwise. Do not persist these and assume they can be read by a future 117 version of the library. 118 1195. Our classes are not designed to protect against a malicious caller. You 120 should not use them for communication between trusted and untrusted code. 121 1226. For the mainline flavor, we test the libraries using OpenJDK 8, 11, and 17 123 on Linux, with some additional testing on newer JDKs and on Windows. Some 124 features, especially in `com.google.common.io`, may not work correctly in 125 non-Linux environments. For the Android flavor, our unit tests also run on 126 API level 21 (Lollipop). 127 128[guava-snapshot-api-docs]: https://guava.dev/releases/snapshot-jre/api/docs/ 129[guava-snapshot-api-diffs]: https://guava.dev/releases/snapshot-jre/api/diffs/ 130[Guava Explained]: https://github.com/google/guava/wiki/Home 131[Guava Beta Checker]: https://github.com/google/guava-beta-checker 132 133<!-- References --> 134 135[using Guava in your build]: https://github.com/google/guava/wiki/UseGuavaInYourBuild 136[repackage]: https://github.com/google/guava/wiki/UseGuavaInYourBuild#what-if-i-want-to-use-beta-apis-from-a-library-that-people-use-as-a-dependency 137[guava-deps]: https://github.com/google/guava/wiki/UseGuavaInYourBuild#what-about-guavas-own-dependencies 138