A native Java binding for Apache OpenDAL™: access S3, GCS, Azure Blob, the local filesystem, and many more services through one API.
We release the OpenDAL Java binding independently of the opendal crate (Rust core). For updates and compatibility, use the Java binding version instead of the opendal crate version.
upgrade.mdThe all classifier bundles the Java API and the JNI libraries for all seven published platforms. Declare a single Maven dependency to compile and run without an OS detector plugin or a separate platform JAR.
<dependency> <groupId>org.apache.opendal</groupId> <artifactId>opendal</artifactId> <version>${opendal.version}</version> <classifier>all</classifier> </dependency>
For Gradle, use implementation "org.apache.opendal:opendal:$opendalVersion:all". The all JAR is about 200 MB. To download only the native library for your target platform, use the default JAR and a platform classifier as shown below.
<build> <extensions> <extension> <groupId>kr.motd.maven</groupId> <artifactId>os-maven-plugin</artifactId> <version>1.7.0</version> </extension> </extensions> </build> <dependencies> <dependency> <groupId>org.apache.opendal</groupId> <artifactId>opendal</artifactId> <version>${opendal.version}</version> </dependency> <dependency> <groupId>org.apache.opendal</groupId> <artifactId>opendal</artifactId> <version>${opendal.version}</version> <classifier>${os.detected.classifier}</classifier> </dependency> </dependencies>
plugins { id "com.google.osdetector" version "1.7.3" } dependencies { implementation "org.apache.opendal:opendal:$opendalVersion" implementation "org.apache.opendal:opendal:$opendalVersion:$osdetector.classifier" }
On musl-based Linux distributions such as Alpine, use the linux-x86_64-musl or linux-aarch_64-musl classifier instead of the detected one.
The native JARs on Maven Central use the opendal dependency features in the binding's Cargo.toml, with SFTP enabled on Unix targets.
Java layers such as RetryLayer and ConcurrentLimitLayer are built in. Exposing a new Rust layer requires Java and JNI binding code.
To add a service, add its feature name, such as "services-d1", to the opendal feature list and run this from bindings/java:
./mvnw clean package -DskipTests=true
Use the resulting JARs in target/, including the JAR with your platform's classifier.
import java.util.HashMap; import java.util.Map; import org.apache.opendal.AsyncOperator; public class Main { public static void main(String[] args) { final Map<String, String> conf = new HashMap<>(); conf.put("root", "/tmp"); try (AsyncOperator op = AsyncOperator.of("fs", conf)) { op.write("/path/to/data", "Hello world").join(); System.out.println(new String(op.read("/path/to/data").join())); } } }
Use the synchronous Operator for blocking calls, or AsyncOperator for CompletableFuture-based calls.
Operator.createReader(path, readerOptions) creates an OperatorReader for repeated reads. ReaderOptions selects versions, conditions, and execution controls; each call selects its own byte range.
ReaderOptions options = ReaderOptions.builder().chunk(8 * 1024 * 1024L).build(); try (OperatorReader reader = op.createReader("large.bin", options)) { byte[] first = reader.read(0, 1024); byte[] next = reader.read(1024, 1024); }
The Java task guide covers streams and resource lifetimes. See ReaderOptions for all supported options, defaults, and constraints.
The full user guide — getting started, connecting to services, common tasks, and going to production — lives at opendal.apache.org/docs/bindings/java.
The Maven source-release.zip includes bindings/java and the Rust core workspace. After extracting it, run ./mvnw package from bindings/java. The wrapper downloads its JAR on first use; the source archive does not bundle it.
This project is built upon the native OpenDAL library and depends on JDK 8 or later. See CONTRIBUTING.md for how to build the binding, run tests, and apply the code style.
Check out the users list for more details on who is using OpenDAL.
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
Apache OpenDAL, OpenDAL, and Apache are either registered trademarks or trademarks of the Apache Software Foundation.
Compiled distributions include the following Mozilla Public License 2.0 components. Their source code is available from the linked project pages:
colored 3.1.1 (source, homepage), licensed under MPL-2.0.option-ext 0.2.0 (source, homepage), licensed under MPL-2.0.persy 1.8.1 (source, homepage), licensed under MPL-2.0.The distribution includes the MPL-2.0 text in META-INF/LICENSE-MPL-2.0.txt.