> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/feature-management-experimentation/new-to-fme/sdks-and-customer-deployed-components/openfeature-providers/java-sdk.md).

# OpenFeature Provider for Java SDK

Integrate your Java applications with Harness FME using the Java OpenFeature Provider, a standardized, vendor-agnostic feature flagging API. This provider implements the OpenFeature specification and bridges the OpenFeature SDK with the Harness FME Java SDK.

This page walks you through installing, configuring, and using the Java OpenFeature provider to evaluate feature flags in your Java applications.

### Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

Before you begin, ensure you have the following:

* A valid [Harness FME SDK key](/feature-management-experimentation/new-to-fme/sdks-and-customer-deployed-components.md#api-keys) for your project
* A Java environment running version 11 or later
* Access to your Maven build configuration

### Version compatibility <a href="#version-compatibility" id="version-compatibility"></a>

| Component                                        | Minimum Version |
| ------------------------------------------------ | --------------- |
| Java                                             | 11+             |
| `@splitsoftware/split-openfeature-provider-java` | ≥ 1.2.1         |
| OpenFeature Java SDK                             | ≥ 1.0.0         |

### Install the provider and dependencies <a href="#install-the-provider-and-dependencies" id="install-the-provider-and-dependencies"></a>

Add the Harness FME OpenFeature provider dependency to your Maven build configuration.

```java
<dependency>
    <groupId>io.split.openfeature</groupId>
    <artifactId>split-openfeature-provider</artifactId>
    <version>1.2.1</version>
</dependency>
```

### Initialize the provider <a href="#initialize-the-provider" id="initialize-the-provider"></a>

You can instantiate and register the provider using your Harness FME SDK key.

```java
import dev.openfeature.sdk.OpenFeatureAPI;
import io.split.openfeature.SplitProvider;

OpenFeatureAPI api = OpenFeatureAPI.getInstance();
api.setProviderAndWait(new SplitProvider("<YOUR_API_KEY>"));
```

Alternatively, if you want more control or need [advanced initialization](/feature-management-experimentation/new-to-fme/sdks-and-customer-deployed-components/server-side-sdks/java-sdk.md#configuration), you can create a `SplitClient` and provide it directly:

```java
import dev.openfeature.sdk.OpenFeatureAPI;
import io.split.openfeature.SplitProvider;
import io.split.client.SplitClient;
import io.split.client.SplitClientConfig;
import io.split.client.SplitFactoryBuilder;

OpenFeatureAPI api = OpenFeatureAPI.getInstance();


SplitClientConfig config = SplitClientConfig.builder()
   .setBlockUntilReadyTimeout(10000)
   .build();
SplitClient splitClient = SplitFactoryBuilder.build("<YOUR_API_KEY>", config).client();
api.setProviderAndWait(new SplitProvider(splitClient));
```

### Construct an evaluation context <a href="#construct-an-evaluation-context" id="construct-an-evaluation-context"></a>

Provide an evaluation context with a targeting key to evaluate flags. The evaluation context passes targeting information such as user IDs, email addresses, or plan types for flag targeting.

For example:

```java
Client client = api.getClient("CLIENT_NAME");

EvaluationContext context = new MutableContext("<TARGETING_KEY>");
Boolean boolValue = client.getBooleanValue("boolFlag", false, context);
```

If the same targeting key is reused across evaluations, set the context at the client or API level:

```java
EvaluationContext context = new MutableContext("<TARGETING_KEY>");
client.setEvaluationContext(context)
```

Or globally:

```java
EvaluationContext context = new MutableContext("<TARGETING_KEY>");
OpenFeatureAPI.getInstance().setEvaluationContext(context)
```

Once the context is set at the client or API level, you don’t need to provide it for each evaluation.

### Evaluate with details <a href="#evaluate-with-details" id="evaluate-with-details"></a>

Use the `get*Details(...)` APIs to get flag values and metadata (such as variant, reason, error code, and configuration). The FME treatment configuration is returned as a raw JSON string under `flagMetadata["config"]`.

For example:

```java
// boolean/string/number/object all have *Details variants:
FlagEvaluationDetails<String> details =
    client.getStringDetails("my-flag", "fallback", ctx);

String jsonConfig = details.getFlagMetadata().getString("config"); // ← Split treatment config
```

### Track events <a href="#track-events" id="track-events"></a>

The Harness FME OpenFeature provider supports tracking user actions or conversion events directly from your Java application.

To enable event tracking, your evaluation context must include the following:

* A non-empty `targetingKey`
* A [`trafficType`](/feature-management-experimentation/management-and-administration/traffic-types.md) (for example, `"user"` or `"account"`)
* A non-blank event name

Optionally, you can include a numeric value and additional event properties. For more information, see [Sending Events](/feature-management-experimentation/management-and-administration/api-best-practices/events.md#event-record-fields).

For example:

```java
MutableContext ctx = new MutableContext("user-123");
ctx.add("trafficType", new Value("user"));

TrackingEventDetails details = new MutableTrackingEventDetails(19.99)
    .add("plan", new Value("pro"))
    .add("coupon", new Value("WELCOME10"));

client.track("checkout.completed", ctx, details);
```

For more information, go to the [Harness FME Java OpenFeature Provider GitHub repository](https://github.com/splitio/split-openfeature-provider-java).
