Skip to content

Latest commit

 

History

History
29 lines (18 loc) · 1.38 KB

File metadata and controls

29 lines (18 loc) · 1.38 KB

LaunchDarkly Sample Java Application


We've built a simple console application that demonstrates how LaunchDarkly's SDK works.


Below, you'll find the basic build procedure, but for more comprehensive instructions, you can visit your Quickstart page or the Java SDK reference guide.

Build instructions


This project uses Gradle. It requires that Java is already installed on your system (version 8 or higher). It will automatically use the latest release of the LaunchDarkly SDK with major version 6.

  1. Edit src/main/java/Hello.java and set the value of SDK_KEY to your LaunchDarkly SDK key. If there is an existing boolean feature flag in your LaunchDarkly project that you want to evaluate, set FEATURE_FLAG_KEY to the flag key.
  static final String SDK_KEY = "1234567890abcdef";

  static final String FEATURE_FLAG_KEY = "my-flag";
  1. On the command line, run ./gradlew run (or, on Windows, gradlew run).

You should see the message "Feature flag '<flag key>' is <true/false> for this context".

Optional: If you wish to see analytic events generated by this sample application, change the SDK configuration to enable events.

    LDConfig config = new LDConfig.Builder()
      .events(Components.sendEvents())
      .build();