MongoDB integration with JVM language engines
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Though the JVM has the Java MongoDB Driver, which can be used by any non-Java language running on the JVM, in practice it is designed for Java and awkward to use in other languages.

The goal of this project is to supply "wrappers" that allow languages running on the JVM to use the Java driver with the culture and paradigms appropriate to that language. It also includes a library to translate directly between BSON and native language types without going through Java types, as well as an extensible JSON encoder/decoder, which supports MongoDB extended JSON for both directions.

Currently the project supports JavaScript via both the Nashorn and Rhino engines. The wrapper attempts to mimic the Node.js MongoDB Driver while also being true to the feature set of the Java driver.

Documentation for the JavaScript classes: MongoClient, MongoDatabase, MongoCollection, MongoCursor, MongoError, and MongoUtil.

As an added bonus, the project comes with a powerful JavaScript shell, essentially a clone for the JVM of the mongo shell that comes with MongoDB. It can do most anything that mongo can do, while also letting you use any JVM library from JavaScript. It is itself written in JavaScript, and as such is very easy to hack and adapt to your particular needs.

To run the shell:

./sincerity mongo

Add "--help" to see command-line options, and run "help" from within the shell to see the commands. The shell supports basic TAB-key completion and UP/DOWN-key persistent history.

You may also be interested in MongoVision, a web-based MongoDB administration interface, which is written in JavaScript using this wrapper.


Full install via Sincerity:

sincerity create mycontainer : attach public three-crickets maven : add com.threecrickets.sincerity.library sincerity-mongodb : install

Maven (for BSON/JSON conversion only):

    <name>Three Crickets Repository</name>

Building MongoDB JVM

To completely build MongoDB JVM you need Ant, Maven and Sincerity.

You may need to create a file named "/build/" (see below) and override the default locations for Maven and Sincerity.

Then, simply change to the "/build/" directory and run "ant".

Your JDK should be at least version 8 in order to support the Nashorn implementation, although there is a workaround for earlier JDK versions (see comment in "/build/".)

During the build process, build and distribution dependencies will be downloaded from an online repository at, so you will need Internet access.

The result of the build will go into the "/build/distribution/" directory. Temporary files used during the build process will go into "/build/cache/", which you are free to delete.

If you only want to build the MongoDB JVM Jar, then you only need Ant (you don't need Maven and Sincerity). Run the "libraries" Ant target instead of the default one.

Configuring the Build

The "/build/" file contains configurable settings, along with some commentary on what they are used for. You are free to edit that file, however to avoid git conflicts, it would be better to create your own "/build/" instead, in which you can override any of the settings. That file will be ignored by git.

To avoid the "bootstrap class path not set" warning during compilation (harmless), configure the "compile.boot" setting in "" to the location of an "rt.jar" file belonging to JVM version 7.