MongoDB Java Driver 5.0 is Released

The MongoDB JVM team is pleased to announce version 5.0.0 of the MongoDB Java Driver!

Release Highlights

MongoDB Java Driver v5 is the latest major release of the driver.

The Java Driver follows semantic versioning. We increment the major version when incompatible, or “breaking” changes are made, and we increment the minor version when functionality is added in a backward-compatible manner.

Because we follow semantic versioning, this increment of the major version is our chance to make breaking changes in the Java driver. That said, we know that major version bumps can be disruptive, particularly when breaking changes are involved, so we have chosen to strike a balance between API modernization and minimization of user impact with these changes.

Farewell to Deprecated Methods and Classes


Most notably, several methods and types related to the StreamFactory interface have been removed in the 5.0 release.

geoHaystack Indexes

Indexes.geoHaystack(), IndexOptions.getBucketSize(), and IndexOptions.bucketSize() have been removed. Instead, you can use a geospatial query operator on a 2d index, or the $geoNear aggregation pipeline stage. More information can be found in the Geospatial Queries page here.

Deprecated DBCollection helper methods

DBCollection.getStats() and .isCapped() helper methods are also both removed as well. You can use $collStats in an aggregation pipeline instead.

For a full list of removals, please consult the documentation here. For a more in-depth look at some of the code changes required to adopt the 5.0 version, please refer to this article.

Other Notable Changes

  • The Scala driver now supports composable Observables (JAVA-4303)
  • To use Vector Search, use Filters.eq() instead of Filters.eqFull() (JAVA-5174)
  • Support for limiting the listCollections command result to collections the user is authorized to use (JAVA-4353)
  • Simplify customization of bson-kotlinx by allowing configuration of the KotlinSerializerCodecProvider (JAVA-5276)
  • BsonDecimal128 values now respond the same way that Decimal128 values do (JAVA-5265)

Upgrading from 4.11 to 5.0

To get started with the latest version of the MongoDB Java Driver, we recommend that you do the following:

  1. First, compile against 4.11 with deprecation warnings enabled. This will help catch any deprecated method or class usage in your application.
  2. Next, remove and replace any deprecated methods or classes in your application.
  3. Finally, confirm that your application is not using any deprecated methods or classes, then begin using the 5.0 driver.


If you have any feedback on the MongoDB Java Driver, or your experience in general building with MongoDB and Java, please leave a note at or file a ticket on our board. Thank you for being a part of the MongoDB community!