Java Quickstart Guide

Connect a Java application to SILO with the MinIO Java SDK.

MinIO Java SDK

SILO implements the S3-compatible server contract, so Java applications can use the upstream MinIO Java SDK directly. The SDK supports Java 8 and later; select a runtime that is also supported by your application framework.

Install the package

Add the dependency to Maven:

XML
<dependency>
  <groupId>io.minio</groupId>
  <artifactId>minio</artifactId>
  <version>9.0.3</version>
</dependency>

Or to Gradle:

KOTLIN
implementation("io.minio:minio:9.0.3")

Configure the connection

BASH
export S3_ENDPOINT=http://127.0.0.1:9000
export S3_ACCESS_KEY=silo-admin
export S3_SECRET_KEY=replace-with-a-strong-secret

Unlike some other MinIO SDKs, the Java builder accepts a complete endpoint URL, including the http:// or https:// scheme. Keep credentials outside source control.

Create a bucket and upload an object

JAVA
import io.minio.BucketExistsArgs;
import io.minio.MakeBucketArgs;
import io.minio.MinioClient;
import io.minio.PutObjectArgs;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;

public final class Quickstart {
  private static String required(String name) {
    String value = System.getenv(name);
    if (value == null || value.isBlank()) {
      throw new IllegalStateException(name + " is required");
    }
    return value;
  }

  public static void main(String[] args) throws Exception {
    MinioClient client =
        MinioClient.builder()
            .endpoint(required("S3_ENDPOINT"))
            .credentials(required("S3_ACCESS_KEY"), required("S3_SECRET_KEY"))
            .build();

    String bucket = "java-quickstart";
    String object = "hello.txt";
    byte[] payload = "hello from SILO\n".getBytes(StandardCharsets.UTF_8);

    boolean exists =
        client.bucketExists(BucketExistsArgs.builder().bucket(bucket).build());
    if (!exists) {
      client.makeBucket(MakeBucketArgs.builder().bucket(bucket).build());
    }

    try (ByteArrayInputStream stream = new ByteArrayInputStream(payload)) {
      client.putObject(
          PutObjectArgs.builder()
              .bucket(bucket)
              .object(object)
              .stream(stream, payload.length, -1)
              .contentType("text/plain")
              .build());
    }

    System.out.printf("Uploaded %s: %d bytes%n", object, payload.length);
  }
}

Use the SDK’s Javadoc and maintained examples for presigned URLs, encryption, notifications, object locking, multipart operations, and other APIs.

Production checklist

  • Use TLS and verify the server certificate and trust store.
  • Load credentials from a secret manager or protected environment.
  • Grant the application only the bucket and object permissions it needs.
  • Pin and test the JDK, SDK, HTTP client, and framework versions together.
  • Configure timeouts and handle SDK exceptions, retries, streams, and incomplete multipart uploads explicitly.

See Identity and Access Management for server-side policy configuration.