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
| Function | Parameters | Returns | Description |
|---|---|---|---|
DeployRamp.init | Config config | void | Initialize the SDK. Build config via new Config.Builder("token").build(). |
DeployRamp.flag | String name | boolean | Evaluate a feature flag by name. |
DeployRamp.flag | String name, Map<String, String> traitOverrides | boolean | Evaluate a feature flag with trait overrides. |
DeployRamp.setTraits | Map<String, String> traits | void | Set traits for flag evaluation. |
DeployRamp.report | Throwable error | void | Report an error for monitoring. |
DeployRamp.report | Throwable error, String flagName, Map<String, String> traitOverrides | void | Report an error associated with a specific flag. |
DeployRamp.close | none | void | Flush pending events and release resources. |