---
updatedAt: 2026-09-25T18:07:53.000Z
agentTools:
  projectIndex: https://docs.atono.io/llms.txt
---

# Implement a feature flag (Java)

```java Java
package org.example;

// import the library
import io.atono.sdk.Atono;

public class Main {

    // configure the SDK once, at startup
    private static final Atono atono = Atono.builder()
      .build("$ENV_KEY");

    static void main() {
        if (atono.getFeatureFlags().getBooleanValue("add_bulk_export_functionality_for_customer_reports", false)) {
          // this code executes when the feature is enabled.
        }
    }
}
```

```json Response Example
{"success":true}
```

# Import the SDK

<!-- java@3-4 -->

Import the `Atono` class from the Atono Java SDK. If you haven't added the SDK to your project yet, add the `io.atono:atono-java-sdk` dependency from Maven Central using Maven or Gradle.

# Initialize the SDK for an environment

<!-- java@8-10 -->

Create the Atono client once, when your application starts, and reuse it for every evaluation. Replace `$ENV_KEY` with your environment key, which you can copy from the Environments page.

# Evaluate the feature flag

<!-- java@13 -->

Call `getBooleanValue()` with the feature flag's name and a fallback value. The SDK returns the fallback value, `false` here, if it can't determine a value for the flag, such as when the flag doesn't exist or no configuration has been retrieved.

If the flag uses customer or location slices, pass an evaluation context as a third argument. The Java SDK doesn't store context globally, so you provide it with each evaluation, typically for the current request.

# Run code when the flag is enabled

<!-- java@13-15 -->

When the flag is enabled (`true`), the code inside the `if` statement runs. When it's disabled, or the SDK falls back to `false`, that code is skipped.