Skip to main content
The official Java binding for RocksDB provides a comprehensive API for JVM-based applications. It includes full support for core RocksDB features including transactions, column families, iterators, and advanced configuration options.

Installation

Add RocksDB as a dependency in your pom.xml:
The rocksdbjni package includes native libraries for Linux, macOS, and Windows. The correct native library is loaded automatically at runtime.

Quick Start

Basic Operations

Configuring Options

Advanced Features

Column Families

Column families allow you to logically partition your data within a single database:

Transactions

RocksDB supports ACID transactions with snapshot isolation:

Iterators

Iterate over keys and values efficiently:

Write Batches

Group multiple writes into an atomic operation:

Multi-Get Operations

Retrieve multiple values in a single operation:

Resource Management

RocksDB objects must be explicitly closed to prevent memory leaks. Always use try-with-resources or explicitly call close().
The Java binding uses JNI to interact with the native RocksDB library. All RocksDB objects extend RocksObject or AbstractNativeReference and must be properly disposed:

Understanding Options

Database Options

Database-wide settings that affect the entire RocksDB instance, including I/O, background jobs, and logging.

Column Family Options

Per-column-family settings for compression, memtables, and compaction. These can be configured independently for each column family.

Mutable Options

Options that can be changed on a running database using setOptions() or setDBOptions() without restarting.

Advanced Options

Fine-tuning options for performance optimization, memory management, and specialized use cases.

Options Hierarchy

The Options class combines both DBOptions and ColumnFamilyOptions:
Many options that appear as database options actually apply as defaults for column families. See the understanding_options.md guide for details.

Platform Support

The Java binding includes native libraries for:
  • Linux (x86_64, ARM64)
  • macOS (x86_64, ARM64)
  • Windows (x86_64)
The correct native library is automatically loaded based on your platform.

Resources

Source Code

Browse the Java binding source code on GitHub

Java API Samples

Complete working examples demonstrating key features

Benchmarks

Performance benchmarks and optimization tips

Release History

Changelog and version history for Java binding

Next Steps

Configuration

Learn about RocksDB configuration options

Performance Tuning

Optimize RocksDB for your workload

Transactions

Deep dive into transaction semantics

Column Families

Advanced column family usage patterns