Split for Java

A feature flag framework for Java that’s free to use and scales with your business.

Start your free trial

Why use Split for Java feature flags?

Split’s Java SDK brings free, scalable feature flags to any app, website or experience built with in the Java language. Split helps teams control rollouts, and customer experiences, while gathering new data and insight on how their products are being engaged.

We focused on two things when building Split: simplicity and performance. Split is quick, secure and easy for anyone to use, especially when it comes to targeting releases or killing problem features. Using Split is the fastest way to start mitigating risk in your releases:

  • Release features to production but disabled for all users by default
  • Target new features only to internal QA teams
  • Slowly roll out features to a broader audience by percentage, demographic, geography, account type, or any other metric
  • Kill features with a single click to revert back to your safe state

Split works across many different languages, letting developers, PMs and support teams control feature rollout from one unified view—and monitor the success of any new code. Our integrations bring rollout updates into the tools your team is already using, further opening the feature-delivery process up to your entire organization.

Looking for Scala feature flag support?

Split’s Java SDK includes support for Scala, allowing customers with either environment to benefit from Split’s full controlled rollout capability without needing to do anything custom.

Getting Started with Split for Java

Getting started with Split is easy—in the case of Java, you just need to add the Split artifact to your project, create a Split client through your favorite injection framework, and then you’re ready to start splitting your code.

Initiating the SDK

Split's Java SDK can be added as a library using your favorite package manager, such as Maven or Gradle.

Here’s an example of adding the Split artifact to a project using Maven for dependency management:

          <dependency>
  io.split.client
  java-client
  1.0.6
</dependency>
        

Once the artifact is in the classpath, it's ready to be imported and ready to be set up.

Creating a Long-lived Client

Next you’ll create a long-lived Split client. You can do this by writing it manually, or injecting it with your favorite dependency injection framework.

Here’s a manual example:

          SplitClient sdk = SplitClientBuilder.build("YOUR_API_KEY")
        

And here’s one using Guice as the injection framework (a similar approach can be used for other frameworks, like Spring):

          public class SplitModule extends AbstractModule {

  @Override
  protected void configure() {}

  @Provides
  @Singleton
  public SplitClient provideSplitClient(@javax.inject.Named("split.api.key") String apiKey) throws Exception {
    return SplitClientBuilder.build(apiKey);
  }
}
        

And that’s it.

Splitting your code.

With the SDK instantiated, it’s now time to start splitting your code base. Find a feature you’d like to split, and wrap it in the split feature flag like so:

          // 'Example' is the name of the feature we are testing.
String treatment = sdk.getTreatment("CUSTOMER_ID","Example");

if (treatment.equals("Example_version_1")) {
	// insert code here to render version one of Example
} else if (treatment.equals("Example_version_2")) {
	// insert code here to render version two of Example
} else if (treatment.equals("Example_version_3")) {
	// insert code here to render version three of Example
} else {
	// This is the default or CONTROL path. Define what to do in case of service degradation.
}
        

The Split Java SDK integrates seamlessly into your code; no other changes or dependencies are needed to get Split up and running.

To continue diving into Split, sign up for a free account today, or dig into our Documentation.

Related Resources