mirror of
https://github.com/zap-proto/dev.git
synced 2026-10-30 15:05:18 +00:00
Folds rich SDK content out of hanzoai/docs into zap-proto/dev (canonical brand). Per-SDK pages: typescript, go, python, rust, cpp, c, java, csharp, ocaml, haskell, erlang. Each carries install, quick-start, client API, gateway, error handling, server impl, and testing. Top-level /sdks/ adds the matrix of all 33 zap-proto repos (core SDKs, community SDKs, wire encoders, editor plugins, tools, protocols over ZAP, spec/research).
76 lines
1.9 KiB
Plaintext
76 lines
1.9 KiB
Plaintext
---
|
|
title: Java
|
|
description: ZAP Java SDK - JVM binding with Netty transport
|
|
---
|
|
|
|
# Java Binding
|
|
|
|
The Java binding provides JVM integration with Netty-based async transport.
|
|
|
|
## Installation
|
|
|
|
Maven:
|
|
```xml
|
|
<dependency>
|
|
<groupId>io.zap</groupId>
|
|
<artifactId>zap-java</artifactId>
|
|
<version>0.1.0</version>
|
|
</dependency>
|
|
```
|
|
|
|
Gradle:
|
|
```groovy
|
|
implementation 'io.zap:zap-java:0.1.0'
|
|
```
|
|
|
|
## Quick Start
|
|
|
|
```java
|
|
import io.zap.*;
|
|
|
|
public class Example {
|
|
public static void main(String[] args) throws Exception {
|
|
try (ZapClient client = Zap.connect("zap://localhost:9000")) {
|
|
ServerInfo server = client.init(new ClientInfo("my-agent", "1.0.0"));
|
|
System.out.println("Connected to: " + server.getName());
|
|
|
|
List<Tool> tools = client.listTools();
|
|
for (Tool tool : tools) {
|
|
System.out.println(" " + tool.getName() + " - " + tool.getDescription());
|
|
}
|
|
|
|
ToolResult result = client.callTool(ToolCall.builder()
|
|
.id("call-1")
|
|
.name("read_file")
|
|
.args("{\"path\": \"/etc/hosts\"}")
|
|
.build());
|
|
|
|
if (result.getError() != null) {
|
|
System.err.println("Error: " + result.getError());
|
|
} else {
|
|
System.out.println("Result: " + new String(result.getContent()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
## Async API
|
|
|
|
```java
|
|
import io.zap.*;
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
CompletableFuture<Void> runAgent() {
|
|
return Zap.connectAsync("zap://localhost:9000")
|
|
.thenCompose(client -> client.initAsync(new ClientInfo("my-agent", "1.0.0"))
|
|
.thenCompose(server -> client.listToolsAsync())
|
|
.thenAccept(tools -> tools.forEach(System.out::println))
|
|
.thenRun(client::close));
|
|
}
|
|
```
|
|
|
|
## Documentation
|
|
|
|
Full documentation at [zap-proto/java](https://github.com/zap-proto/java).
|