> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up Java SDK

> Install and initialize the LaunchDarkly Java SDK

> For the complete documentation index, see [llms.txt](/llms.txt). For the full documentation snapshot, see [llms-full.txt](/llms-full.txt).

<div>
  <ReadmeButton sdk={SDK.Java} />

  <CursorButton sdk={SDK.Java} />
</div>

### Install the package

<CodeGroup>
  ```xml title={"XML"} theme={null}
    <dependency>
      <groupId>com.launchdarkly</groupId>
      <artifactId>launchdarkly-java-server-sdk</artifactId>
      <version>7.0.0</version>
    </dependency>

  ```

  ```groovy title={"Gradle"} theme={null}
    implementation group: 'com.launchdarkly', name: 'launchdarkly-java-server-sdk', version: '7.0.0'

  ```
</CodeGroup>

### Initialize the SDK

```java title={"Java SDK initialization"} theme={null}
import com.launchdarkly.sdk.*;
import com.launchdarkly.sdk.server.*;

public class Main {
  public static void main(String[] args) {
    LDConfig config = new LDConfig.Builder().build();

    // Set your LaunchDarkly SDK key.
    // This is inlined as example only for onboarding.
    // Never hardcode your SDK key in production.
    final LDClient client = new LDClient("YOUR_SDK_KEY", config);

    if (client.isInitialized()) {
      // For onboarding purposes only we flush events as soon as
      // possible so we quickly detect your connection.
      // You don't have to do this in practice because events are automatically flushed.
      client.flush();
      System.out.println("SDK successfully initialized!");
    }
  }
}

```

<Accordion title="Finding your SDK credentials">
  You can find your server-side SDK key, client-side ID, and mobile key in the "Resources" section of the help menu. Click the **help icon** at the bottom left corner of the LaunchDarkly UI, then choose **SDK keys**:

  <Frame caption="The SDK keys option in the help menu.">
    ![The SDK keys option in the help menu.](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/28d3e1c568378ea02528db7ba62bfbd742f6f1cad964b5675395e10af5eeeb60/assets/images/auto/help-menu-sdk-keys.auto.png)
  </Frame>
</Accordion>

To learn more, read [Initialize the client](/sdk/server-side/java#initialize-the-client) in the Java SDK reference guide.
