One change
java
cli-sdks-libraries/sdks/java
Nearest release: v2.1.238, published under an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
cli-sdks-libraries/sdks/java Changed · +18 / -29 lines
from line 15
<Tabs> <Tab title="Gradle"> ```kotlin - implementation("com.anthropic:anthropic-java:2.53.0") + implementation("com.anthropic:anthropic-java:2.57.0") ``` </Tab>
from line 24
<dependency> <groupId>com.anthropic</groupId> <artifactId>anthropic-java</artifactId> - <version>2.53.0</version> + <version>2.57.0</version> </dependency> ``` </Tab>
from line 466
```java import com.anthropic.core.MultipartField; -import com.anthropic.models.beta.files.FileMetadata; -import com.anthropic.models.beta.files.FileUploadParams; +import com.anthropic.models.files.FileMetadata; +import com.anthropic.models.files.FileUploadParams; FileUploadParams params = FileUploadParams.builder() .file(
from line 478
) .build(); -FileMetadata fileMetadata = client.beta().files().upload(params); +FileMetadata fileMetadata = client.files().upload(params); ``` Or from an `InputStream`:
from line 485
```java import com.anthropic.core.MultipartField; -import com.anthropic.models.beta.files.FileMetadata; -import com.anthropic.models.beta.files.FileUploadParams; +import com.anthropic.models.files.FileMetadata; +import com.anthropic.models.files.FileUploadParams; FileUploadParams params = FileUploadParams.builder() .file(
from line 498
) .build(); -FileMetadata fileMetadata = client.beta().files().upload(params); +FileMetadata fileMetadata = client.files().upload(params); ``` Or from in-memory bytes:
from line 505
```java import com.anthropic.core.MultipartField; -import com.anthropic.models.beta.files.FileMetadata; -import com.anthropic.models.beta.files.FileUploadParams; +import com.anthropic.models.files.FileMetadata; +import com.anthropic.models.files.FileUploadParams; FileUploadParams params = FileUploadParams.builder() .file(
from line 518
) .build(); -FileMetadata fileMetadata = client.beta().files().upload(params); +FileMetadata fileMetadata = client.files().upload(params); ``` ### Binary responses
from line 528
```java import com.anthropic.core.http.HttpResponse; -HttpResponse response = client.beta().files().download("file_abc123"); +HttpResponse response = client.files().download("file_abc123"); ``` To save the response content to a file:
from line 536
```java import com.anthropic.core.http.HttpResponse; -try (HttpResponse response = client.beta().files().download(params)) { +try (HttpResponse response = client.files().download(params)) { Files.copy( response.body(), Paths.get(path),
from line 553
```java import com.anthropic.core.http.HttpResponse; -try (HttpResponse response = client.beta().files().download(params)) { +try (HttpResponse response = client.files().download(params)) { response.body().transferTo(Files.newOutputStream(Paths.get(path))); } catch (Exception e) { IO.println("Something went wrong!");
from line 1137
``` <Accordion title="Jackson compatibility"> - The SDK depends on Jackson for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default. + The SDK depends on Jackson for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.19.4 by default. The SDK throws an exception if it detects an incompatible Jackson version at runtime (for example, if the default version was overridden in your Maven or Gradle config).
from line 1200
You can access most beta API features through the `beta()` method on the client. To enable a particular beta feature, add the appropriate [beta header](https://platform.claude.com/docs/en/api/beta-headers) with `.addBeta()` when building the message params. -For example, to use the [Files API](https://platform.claude.com/docs/en/build-with-claude/files): +For example, to enable [context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing): ```java import com.anthropic.models.beta.AnthropicBeta; -import com.anthropic.models.beta.messages.BetaContentBlockParam; import com.anthropic.models.beta.messages.BetaMessage; -import com.anthropic.models.beta.messages.BetaRequestDocumentBlock; -import com.anthropic.models.beta.messages.BetaTextBlockParam; import com.anthropic.models.beta.messages.MessageCreateParams; // ... void main() {
from line 1214
MessageCreateParams.builder() .model(Model.CLAUDE_OPUS_5) .maxTokens(1024L) - .addBeta(AnthropicBeta.FILES_API_2025_04_14) - .addUserMessageOfBetaContentBlockParams(List.of( - BetaContentBlockParam.ofText( - BetaTextBlockParam.builder() - .text("Please summarize this document for me.") - .build()), - BetaContentBlockParam.ofDocument( - BetaRequestDocumentBlock.builder() - .fileSource("file_abc123") - .build()))) + .addBeta(AnthropicBeta.CONTEXT_MANAGEMENT_2025_06_27) + .addUserMessage("Hello, Claude") .build()); } ```