Java SDK

The DeployRamp Java SDK lets you evaluate feature flags, report errors, and manage traits from any JVM application. It shares the same artifact as the Kotlin SDK, so you can use either language in the same project.

Installation

Add the dependency to your Maven pom.xml:

<dependency>
  <groupId>com.deployramp</groupId>
  <artifactId>deployramp-sdk</artifactId>
  <version>0.1.0</version>
</dependency>

Initialization

Initialize the SDK with your public token before evaluating any flags. Use Config.Builder to construct the configuration:

import com.deployramp.sdk.Config;
import com.deployramp.sdk.DeployRamp;

DeployRamp.init(new Config.Builder("pk_live_abc123").build());

Evaluating Flags

Call DeployRamp.flag() with the flag name to check whether a feature is enabled. You can optionally pass trait overrides as a second argument:

if (DeployRamp.flag("new-checkout")) {
    // new checkout flow
}

// With trait overrides
Map<String, String> overrides = Map.of("plan", "enterprise");
if (DeployRamp.flag("new-checkout", overrides)) {
    // enterprise-only checkout flow
}

Setting Traits

Traits are key-value pairs that describe the current user or environment. They influence flag evaluation on the server:

DeployRamp.setTraits(Map.of(
    "plan", "pro",
    "region", "us-east-1"
));

Error Reporting

Report caught exceptions so DeployRamp can correlate errors with flag rollouts and trigger automatic rollbacks when needed:

try {
    processPayment();
} catch (Exception e) {
    DeployRamp.report(e, "new-checkout", null);
}

Shutdown

Call close() when your application is shutting down to flush any pending events and release resources:

DeployRamp.close();

API Reference

FunctionParametersReturnsDescription
DeployRamp.initConfig configvoidInitialize the SDK. Build config via new Config.Builder("token").build().
DeployRamp.flagString namebooleanEvaluate a feature flag by name.
DeployRamp.flagString name, Map<String, String> traitOverridesbooleanEvaluate a feature flag with trait overrides.
DeployRamp.setTraitsMap<String, String> traitsvoidSet traits for flag evaluation.
DeployRamp.reportThrowable errorvoidReport an error for monitoring.
DeployRamp.reportThrowable error, String flagName, Map<String, String> traitOverridesvoidReport an error associated with a specific flag.
DeployRamp.closenonevoidFlush pending events and release resources.

We use cookies to analyze site usage and improve your experience.