Java - 5 Minute Test
Get Featureflow running in your Java application in under 5 minutes.
Prerequisites
If you haven't already, create a free Featureflow account. New accounts include a default project with test and production environments, plus an example feature.
1. Clone the Example Project
git clone https://github.com/featureflow/featureflow-fiveminute-java.git
cd featureflow-fiveminute-java
2. Add Your API Key
Edit HelloWorld.java and replace the placeholder with your Server Environment API Key.
On your project page, find the Environments section and click the key icon next to your environment:

Copy the Server SDK API Key (starts with sdk-srv-env-):

Update the code:
FeatureFlowClient client = new FeatureFlowClient.Builder("srv-env-YOUR_API_KEY")
3. Get the Feature Key
The example uses example-feature. You can find feature keys in the Features section of your project:

The feature key is shown in the KEY column (e.g., my-new-feature, example-feature).
4. Build and Run
./mvnw clean compile assembly:single
java -jar target/featureflow-fiveminute-java-1.0.0-SNAPSHOT-jar-with-dependencies.jar
With the default configuration, you should see:
The variant is not on!
5. Toggle the Feature
In the Featureflow dashboard, enable the example-feature in your environment. The application will receive the update in real-time:
Received a control update event: example-feature variant: on
Congratulations! You've successfully integrated Featureflow.
Going Further: User Targeting
Want to target features to specific users? Try the HelloWorldWithUser example.
1. Update the Main Class
Edit pom.xml to use HelloWorldWithUser:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>HelloWorldWithUser</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
2. Add Your API Key
Update HelloWorldWithUser.java with your Server API Key.
3. Build and Run
./mvnw clean compile assembly:single
java -jar target/featureflow-fiveminute-java-1.0.0-SNAPSHOT-jar-with-dependencies.jar
The new-feature will be automatically registered in Featureflow.
4. Create a Targeting Rule
In Featureflow:
- Click Update Rules for
example-feature - Click Add Rule
- Set: IF
user_roleequalsadmin→ show varianton - Set the default (ELSE) to variant
off

Since the example user has an admin role, the feature will be enabled. Change the role to standard_user in the code and rerun — the feature will be disabled.
5. Add Custom Variants
You can add more variants beyond on/off:
- Click the feature name to edit settings
- Click Add Variant and create an
enhancedvariant - Update rules to show
enhancedtopvt_testerusers
FeatureflowUser user = new FeatureflowUser("flo@example.com")
.withAttribute("age", 32)
.withAttribute("signup_date", new DateTime(2017, 1, 1, 12, 0, 0, 0))
.withStringAttributes("user_role", Arrays.asList("pvt_tester"))
.withAttribute("tier", "gold");
Next Steps
- Gradual rollouts — release to a percentage of users
- Managing variants — create custom feature states
- Targeting features — control who sees what
- Quick Start - Frontend — add client-side feature flags