Skip to content

Feature flags in Java and Spring Boot: SDKs compared, Togglz, FF4j and OpenFeature

How to use feature flags in Java and Spring Boot: Maven artifacts, the Java version each jar is compiled for and evaluation modes of 18 libraries, tested Spring Boot 4.1 code for OpenFeature with flagd and for Togglz, and the Spring starters that exist.

10 min read

Short answer: Most Java flag SDKs download the rules and evaluate flags in the JVM, refreshed by a background thread, so a check doesn't call the network. In Spring Boot, create the client once as a bean, set the user per request in a filter, and close the client on shutdown. Java also has embedded libraries, Togglz and FF4j, that keep flag state in your own database.

Which Java SDKs are there, and how do they evaluate?

Artifact versions from Maven Central, checked on 15 November 2026. "Compiled for" is the class file version of the jar we downloaded, which sets the oldest Java that can load it; evaluation modes come from each vendor's docs.

Tool Maven artifact Compiled for How the Java SDK evaluates
OpenFeature dev.openfeature:sdk 1.23.0 Java 11 Depends on the provider
LaunchDarkly com.launchdarkly:launchdarkly-java-server-sdk 7.18.0 Java 8 Locally, from state the SDK keeps current, "without making any remote requests" per flag
Unleash io.getunleash:unleash-client-java 12.3.2 Java 11 Locally, refreshing every 15 seconds by default
GrowthBook com.github.growthbook.growthbook-sdk-java:lib 0.12.0 (JitPack, not Maven Central) Java 8 Locally from cached features; remote evaluation is opt-in
Flagsmith com.flagsmith:flagsmith-java-client 8.5.0 Java 11 Remotely by default, a blocking request per call; local evaluation is opt-in and refreshes every 60 seconds
ConfigCat com.configcat:configcat-java-client 10.1.0 Java 8 Locally, auto polling every 60 seconds by default
PostHog com.posthog:posthog-server 2.24.2 (the older com.posthog.java:posthog stopped at 1.2.0) Java 8 Remotely by default; local evaluation polls every 30 seconds and needs a personal API key
Statsig com.statsig:javacore 0.24.0 (the legacy SDK is com.statsig:serversdk) Java 8, plus native libraries Synchronously in the SDK after initialization, with background updates
DevCycle com.devcycle:java-server-sdk 2.10.1 Java 11 Locally with a bundled WASM bucketing library (polls every 30 seconds by default), or cloud bucketing
Split / Harness FME io.split.client:java-client 4.19.1 Java 8 From an in-memory cache, kept current by streaming by default, or polling every 60 seconds
Optimizely com.optimizely.ab:core-api 4.7.0 Java 8 Locally, from a datafile
FeatBit co.featbit:featbit-java-sdk 1.5.1 Java 8 Locally and synchronously, with data synced over WebSocket
Flipt io.flipt:flipt-client-java 1.4.0 Java 8, plus a native library In the SDK with a native engine, polling every 120 seconds by default
flagd dev.openfeature.contrib.providers:flagd 0.15.0 Java 11 Remote over gRPC (the default), in-process, or from a local file
GO Feature Flag dev.openfeature.contrib.providers:go-feature-flag 2.0.2 on Maven Central (2.1.0 tagged on GitHub) Java 11 In-process by default (polls the relay proxy every 120 seconds), or remote
Azure App Configuration com.azure.spring:spring-cloud-azure-feature-management 7.4.0 Java 17 Locally, from flags loaded into the Spring app
Togglz org.togglz:togglz-core 4.6.4 Java 17 In the JVM, from a state repository you choose (properties, file, JDBC and others)
FF4j org.ff4j:ff4j-core 3.0.0 Java 21 In the JVM, from a feature store you choose (20+ backends)

Sources: Maven Central metadata for versions; class file versions read from each jar with a script. Evaluation modes: the tool profiles and LaunchDarkly Java, Unleash Java, GrowthBook Java, Flagsmith server-side SDKs, ConfigCat Java, PostHog Java, Statsig Java Core and its legacy SDK page, DevCycle Java README and polling default in the source, Harness FME Java SDK, Optimizely Java SDK, FeatBit Java SDK, Flipt Java client, flagd Java provider, GO Feature Flag Java provider, Azure Spring Boot quickstart, Togglz, FF4j.

The documented minimums mostly match the bytecode: Unleash needs Java 11 from v11 (pin 10.2.x for Java 8), Flagsmith states JDK 11+, DevCycle Java 11, and Split, ConfigCat, FeatBit, Optimizely and Statsig Java Core Java 8. Two SDKs load native code: Statsig Java Core ships native libraries for Linux (x86_64 and arm64, with musl variants), macOS (x86_64 and arm64) and Windows x86_64, and Alpine needs libgcc and gcompat; Flipt's client wraps a native engine for Linux, macOS and Windows x86_64 and Linux and macOS arm64. DevCycle's local bucketing needs an x86_64 or aarch64 JDK and glibc 2.16 or later.

Which Spring Boot starters exist?

Library Spring artifact Compiled for Spring Boot
Togglz org.togglz:togglz-spring-boot-starter 4.6.4 Java 17 Togglz 4.0 to 4.5 target Spring Boot 3; 4.6.0 (February 2026) moved to Spring Boot 4. We ran 4.6.4 on Spring Boot 4.1.2
Unleash io.getunleash:springboot-unleash-starter 2.0.0 Java 17 2.0.0 moved the baseline to Spring Boot 4
Azure App Configuration com.azure.spring:spring-cloud-azure-feature-management 7.4.0 Java 17 The 7.x line depends on Spring Boot 4 (7.4.0 on 4.1.0); Spring Boot 3 apps use the 6.x line
FF4j org.ff4j:ff4j-spring-boot-starter-webmvc 2.1 (GitHub release May 2024), a separate project Java 21 Built for Spring Boot 3.2 and FF4j 2.1
OpenFeature and vendor SDKs No starter in their docs Register the client as a bean (below)

Sources: Togglz 4.0.0 and 4.6.0 release notes, Unleash Spring Boot starter and its v2.0.0 release, the Azure 7.4.0 POM and Spring Boot quickstart (JDK 17), the FF4j starter releases and parent POM. Unleash's starter also adds a @Toggle annotation that swaps one bean implementation for another when a flag is on.

How do I use OpenFeature in Spring Boot?

Register the API as a bean that shuts down with the context, and set the current user in a servlet filter with a thread-local transaction context, so services check flags without receiving the user. We built and ran this with Spring Boot 4.1.2 on Java 21, dev.openfeature:sdk 1.23.0 and the flagd provider 0.15.0 reading a local file:

@Configuration
public class FeatureFlagConfig {

    @Bean(destroyMethod = "shutdown")
    public OpenFeatureAPI openFeature() {
        OpenFeatureAPI api = OpenFeatureAPI.getInstance();
        api.setTransactionContextPropagator(new ThreadLocalTransactionContextPropagator());
        api.setProviderAndWait(new FlagdProvider(FlagdOptions.builder()
                .resolverType(Config.Resolver.FILE)
                .offlineFlagSourcePath("flags.json")
                .build()));
        return api;
    }

    @Bean
    public Client featureClient(OpenFeatureAPI api) {
        return api.getClient();
    }
}
@Component
public class FlagContextFilter extends OncePerRequestFilter {

    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
            throws ServletException, IOException {
        String userId = Objects.requireNonNullElse(request.getHeader("X-User-Id"), "anonymous");
        String plan = Objects.requireNonNullElse(request.getHeader("X-Plan"), "free");
        OpenFeatureAPI api = OpenFeatureAPI.getInstance();
        api.setTransactionContext(new ImmutableContext(userId, Map.of("plan", new Value(plan))));
        try {
            chain.doFilter(request, response);
        } finally {
            api.setTransactionContext(new ImmutableContext());
        }
    }
}
@RestController
public class CheckoutController {

    private final Client flags;

    public CheckoutController(Client flags) {
        this.flags = flags;
    }

    @GetMapping("/checkout")
    public String checkout() {
        return flags.getBooleanValue("new-checkout", false) ? "New checkout" : "Old checkout";
    }
}

With a flags.json whose new-checkout rule is on when plan equals pro, a request with X-Plan: pro returned "New checkout" and one without it "Old checkout". 200 requests sent 20 at a time with alternating plans each got their own result, editing flags.json while the app ran took effect within about 4 seconds (file mode re-reads it every 5 seconds by default), and on SIGTERM Spring shut down gracefully. Imports are from dev.openfeature.sdk, dev.openfeature.contrib.providers.flagd, jakarta.servlet and Spring. setProviderAndWait throws if the provider can't start (for example, a missing file), so the app fails at startup rather than serving defaults silently.

Points that matter in production:

  • Clear the context in finally. Servlet containers reuse threads, so a thread-local context left behind would apply to the next request on that thread.
  • Other threads and dispatches. Work you hand to another thread (@Async, executors) doesn't carry the thread-local context; pass the evaluation context explicitly or copy it with a TaskDecorator. OncePerRequestFilter also skips async and error dispatches by default, so code running after a Callable or DeferredResult returns, or in /error, has no context.
  • Reactive apps. WebFlux doesn't run servlet filters, and a thread-local context doesn't follow a pipeline across threads; pass the context with each evaluation instead.
  • Spring Boot fat jars and flagd. On a full JDK, the flagd provider 0.15.0 turns on targeting rule compilation automatically. Run from a Spring Boot executable jar, javac couldn't see the provider's classes inside the nested jars: each rule logged a long compiler warning and fell back to interpretation, with correct results. Setting FLAGD_COMPILE_TARGETING=disabled, or running on a JRE image (no jdk.compiler), removed the warning in our test on Java 21. The README marks rule compilation as experimental; on Java 24 and later it compiles with the built-in Class-File API instead of javac, which also works on JRE images, and the provider accepts any flagd-core 3.x, so pin it if you need repeatable builds (flagd provider options).
  • Use real identity. Take the user from Spring Security or your session, not from headers the client controls; the same applies to the Togglz example below.
  • Tests. The Java SDK includes an InMemoryProvider for fixed flag values in tests.

How do I use Togglz in Spring Boot?

Togglz declares features as a Java enum, keeps their state in a repository you pick, and decides with activation strategies. We ran this with togglz-spring-boot-starter 4.6.4 on Spring Boot 4.1.2: requests from alice got "New checkout", carol and anonymous requests "Old checkout".

public enum Features implements Feature {

    @Label("New checkout flow")
    NEW_CHECKOUT
}
# application.yml
togglz:
  feature-enums: com.example.demo.Features
  features:
    NEW_CHECKOUT:
      enabled: true
      strategy: username
      param:
        users: alice,bob
@Configuration
public class TogglzConfig {

    // Without Spring Security, tell Togglz who the user is
    @Bean
    public UserProvider userProvider() {
        return () -> {
            if (RequestContextHolder.getRequestAttributes() instanceof ServletRequestAttributes attrs) {
                String userId = attrs.getRequest().getHeader("X-User-Id");
                return userId == null ? null : new SimpleFeatureUser(userId);
            }
            return null;
        };
    }
}

Check a feature with an injected FeatureManager: features.isActive(Features.NEW_CHECKOUT). With Spring Security, add the optional togglz-spring-security module and it provides the user instead of the bean above. Notes from the run: the starter pulls in Thymeleaf (for Togglz's Thymeleaf dialect), which logged a warning about the missing templates/ folder. The admin console is a separate togglz-console dependency, inaccessible without Spring Security unless you set togglz.console.secured=false. The default state repository is in memory: changes made at runtime through the console or the actuator endpoint are lost on restart, so use togglz.features-file or a JDBC state repository to keep them (Togglz Spring Boot starter).

Should I use an embedded library or a flag service?

  • Togglz or FF4j suit one Java application or a few that share a database: no extra service, state in your database, an optional web console. FF4j 3.0 (September 2026, "Librairies updates and CVE fixes") is compiled for Java 21, as 2.1 already was, and built on Spring Framework 6.2; its Spring Boot starter is a separate project last released in May 2024 for Spring Boot 3.2.
  • Plain Spring properties (@ConditionalOnProperty, or values refreshed with Spring Cloud Config) are enough for a few on/off switches, without per-user rules.
  • A flag service (Unleash, Flagsmith, GrowthBook, flagd and the SaaS tools above) fits several services or languages, percentage rollouts with consistent bucketing across services, experiments and audit logs. See self-hosted vs SaaS feature flags.
  • OpenFeature keeps the evaluation calls the same across the services that have Java providers (flagd, GO Feature Flag, Unleash, Flagsmith, Statsig, ConfigCat, Optimizely, Flipt and OFREP in the contrib repository, and LaunchDarkly's own provider); provider setup and context mapping still change. There is no provider for Togglz or FF4j.

What else should I watch?

  • One client per JVM. LaunchDarkly says to make LDClient a singleton for each project, Statsig Java Core keeps one shared instance (Statsig.newShared) per process, and FeatBit says applications "SHOULD instantiate a single FBClient instance"; a Spring singleton bean does this.
  • Startup. Before Split's SDK is ready, getTreatment returns the control treatment; blockUntilReady() waits and throws a TimeoutException after the configured timeout, and FeatBit's constructor blocks for up to 15 seconds by default, then serves defaults if not connected.
  • Shutdown. Call close() (LaunchDarkly, ConfigCat, Flagsmith, PostHog, FeatBit, Flipt, DevCycle, Optimizely), shutdown() (OpenFeature, Statsig, GrowthBook, Unleash) or destroy() (Split, which also registers a JVM shutdown hook) so background threads stop and events are sent. @Bean(destroyMethod = ...) handles this in Spring.
  • Remote evaluation on hot paths. Flagsmith and PostHog evaluate remotely by default; turn on local evaluation for flags checked on every request.
  • Moved repositories and artifacts. LaunchDarkly's java-server-sdk repository is archived and the code now lives in launchdarkly/java-core; PostHog's Java docs use com.posthog:posthog-server; GrowthBook's 0.11 changed its JitPack coordinates to ...:lib and requires OkHttp 5.

How did we check the Java versions?

We downloaded each jar from Maven Central and read the major version of every .class file outside META-INF, then counted them (52 is Java 8, 55 Java 11, 61 Java 17, 65 Java 21). The script, its artifact list and the raw results are published; run sh run.sh next to class_versions.py to reproduce. LaunchDarkly's and Split's jars also contain older-format classes from shaded dependencies (javax and SnakeYAML); their own classes target Java 8. For the Spring starters we read the auto-configuration jar, since the Unleash starter itself is only a POM; GrowthBook's jar comes from JitPack, so we checked it separately. A jar compiled for Java 8 runs on newer JVMs, but its documented minimum is still the one to follow.

For other languages, see feature flags in Go, Python and Node.js; for Android and iOS, feature flags in mobile apps. On speed, see local vs remote evaluation. To pick a tool, see the best feature flag tools or the directory.