> ## Java SDK

> Java SDK for Antithesis

> Fetch the complete documentation index at: https://antithesis.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

---

The Antithesis Java SDK offers classes to use Antithesis functionality in your Java code under test. It's available on [Github](https://github.com/antithesishq/antithesis-sdk-java) and as a JAR on [Maven Central](https://central.sonatype.com/artifact/com.antithesis/sdk).

### Prerequisites

- Java 8 or higher.

If you want to use a different version, contact us at support@antithesis.com or [ask on our Discord](https://discord.com/invite/antithesis).

### Classes

The SDK provides three classes which each offer different functionality.

- The [Assert](/docs/generated/sdk/java/com/antithesis/sdk/Assert.html) class methods let you [define test properties](/docs/reference/sdk/) in your software or test template.
- The [Random](/docs/generated/sdk/java/com/antithesis/sdk/Random.html) class methods request structured and unstructured [randomness](/docs/reference/sdk/) from the Antithesis platform.
- The [Lifecycle](/docs/generated/sdk/java/com/antithesis/sdk/Lifecycle.html) class methods inform Antithesis that [particular phases or milestones have been reached](/docs/reference/sdk/).

### SDK runtime behavior

The SDK has sensible fallback behaviors that enable you to have a single build of your software that runs both inside and outside Antithesis.

One benefit of this is that [Sometimes Assertions](/docs/concepts/properties_assertions/sometimes_assertions/) continue to function outside Antithesis, and can be quite useful for discovering what states of your program are encountered during real-world use.

#### Fallback behavior for methods in Assert and Lifecycle

Methods in the Assert and Lifecycle classes have two modes for when your software is running **outside** Antithesis, including in production:

1. **Default**
   This mode is the default behavior, where `assert` and `lifecycle` use local implementations of Antithesis functionality. However, the results will not be logged anywhere because no logfile has been specified.

2. **Default with logging**
   The same as the above but logs output locally in [a structured JSON format](/docs/reference/sdk/fallback/schema/).

   This mode is useful for dicovering what states of your program are encountered during real-world use.

   This mode is selected at runtime by setting the environment variable `ANTITHESIS_SDK_LOCAL_OUTPUT` at program startup.
   This variable must be set to a filepath: a logfile will be created at this location. The file must be located inside an already-existing directory. You may supply either a relative or absolute path.

   E.g. set `ANTITHESIS_SDK_LOCAL_OUTPUT=assertions_20240520.json` at startup.

#### Fallback behavior for methods in Random

Methods in the [Random](/docs/generated/sdk/java/com/antithesis/sdk/Random.html) class always fall back upon the [java.util.Random](https://docs.oracle.com/javase/8/docs/api/java/util/Random.html) class for entropy when run outside of Antithesis.
