Getting started with Java SDK

This section describes how to set up and install the Java SDK and how to deploy a feature flag.

Step 1: Setting up

To setup Java SDK, follow these steps:

  1. Create a CloudBees Feature Management account. See Signup Page to create an account.

  2. Get your environment key.

    • Get the key from App Settings > Environment > Key.

Step 2: Installing the Java Server SDK

Add the CloudBees Feature Management Java Server package to your application by adding the following in the dependencies block:

build.gradle Maven - pom.xml
implementation 'io.rollout.rox:rox-java-server:4.+'----

Create a container class called with the following code. This container class is where we will define all of our feature flags.

import io.rollout.flags.RoxFlag;
import io.rollout.configuration.RoxContainer;

// Create Roxflags in the Flags container class
public class Flags implements RoxContainer {
  // Define the feature flags
  public RoxFlag enableTutorial = new RoxFlag(false);
  public RoxVariant titleColors = new RoxVariant("White", new String[] {"White", "Blue", "Green"});


Add the following lines of code to your application:

// Initialize container class that we created earlier
Flags flags = new Flags();

// Register the flags container

// Setup the environment key

// Boolean flag example
if (flags.enableTutorial.isEnabled()) {
  // TODO:  Put your code here that needs to be gated

// Multivariate flag example
if (flags.titleColors.value().equals("White")) {
  System.out.println("Title color is white");
} else if (flags.titleColors.value().equals("Blue")) {
  System.out.println("Title color is blue");
} else if (flags.titleColors.value().equals("Green")) {
  System.out.println("Title color is green");

Container class registration and environment key setup

  • You cannot call Rox.setup() twice in the same runtime.

Run your application

Running the application

The flag name is automatically added to the CloudBees Feature Management dashboard after running the application.