# Java

The Java SDK talks to `antd` over REST by default and also exposes async and gRPC clients.

## Install

```kotlin
dependencies {
    implementation("com.autonomi:antd-java:0.1.0")
}
```

## Connect to the daemon

```java
import com.autonomi.antd.AntdClient;

try (var client = new AntdClient()) {
    var health = client.health();
    System.out.println(health.network());
}
```

The SDK also provides `AsyncAntdClient` and `GrpcAntdClient`.

## Store and retrieve data

```java
import com.autonomi.antd.AntdClient;

public class QuickStart {
    public static void main(String[] args) throws Exception {
        try (var client = new AntdClient()) {
            var result = client.dataPutPublic("Hello, Autonomi!".getBytes());
            System.out.println(result.address());

            byte[] data = client.dataGetPublic(result.address());
            System.out.println(new String(data));
        }
    }
}
```

## Type mappings

| Autonomi type  | Java type                               |
| -------------- | --------------------------------------- |
| `HealthStatus` | `com.autonomi.antd.models.HealthStatus` |
| `PutResult`    | `com.autonomi.antd.models.PutResult`    |
| Raw data       | `byte[]`                                |

## Error handling

```java
try {
    byte[] data = client.dataGetPublic("bad-address");
} catch (com.autonomi.antd.NotFoundException e) {
    System.out.println("Data not found");
} catch (com.autonomi.antd.PaymentException e) {
    System.out.println("Insufficient funds");
} catch (com.autonomi.antd.AntdException e) {
    System.out.println(e.getMessage());
}
```

## Full API reference

For all available daemon endpoints, see the [REST API](/developers/sdk/install/reference/rest-api.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.autonomi.com/developers/sdk/install/reference/language-bindings/java.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
