This is a simple console application that demonstrates how LaunchDarkly's Java SDK works with the LaunchDarkly Relay Proxy in Daemon Mode with Redis.
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.
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 5.
- Edit
src/main/java/Hello.javaand set the value ofSDK_KEYto your LaunchDarkly SDK key. If there is an existing boolean feature flag in your LaunchDarkly project that you want to evaluate, setFEATURE_FLAG_KEYto the flag key. You will also need to set the value ofREDISto the URI of your Redis host as well as theREDIS_PREFIXto your specific Redis cache.
static final String SDK_KEY = "sdk-1234567890abcdef";
static final String FEATURE_FLAG_KEY = "my-flag";
static final String REDIS = "http://your-redis-host:6379";
static final String REDIS_PREFIX = "your-redis-cache";- 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 user".