> ## Documentation Index
> Fetch the complete documentation index at: https://cobo.com/developers/llms.txt
> Use this file to discover all available pages before exploring further.

# Get started with Java SDK

> Learn to integrate, configure, and use the Java SDK with code samples for seamless app development.

<Tip>
  Try [Cobo WaaS Skill](/v2/guides/overview/cobo-waas-skill) in your AI coding assistant (Claude Code, Cursor, etc.). Describe your needs in natural language to auto-generate production-ready SDK code and debug faster 🚀
</Tip>

## Overview

This guide introduces how to get started with using the Cobo WaaS 2.0 Java SDK, which allows you to integrate the WaaS service into your existing application using the Java programming language.

To learn more about the initial setup steps necessary for utilizing the WaaS API, see [Send your first request](/v2/guides/get-started/get-started-with-waas).

You can go to [GitHub](https://github.com/CoboGlobal/cobo-waas2-java-sdk/) to access the source code of the SDK.

## Prerequisites

* Install Java 1.8 or newer

* Install Maven 3.8.3 or newer / Gradle 7.2 or newer

* Follow the instructions in [Set up your account and organization](https://manuals.cobo.com/en/portal/quick-start-guide) to set up your Cobo account and create your organization. If an organization has already been set up, ask your organization admin to invite you to join the organization.

* You have [generated an API key and an API secret](/v2/guides/overview/cobo-auth#generate-an-api-key-and-an-api-secret), and [registered the API key](https://manuals.cobo.com/en/portal/developer-console/create-api-key) on Cobo Portal.

## Add dependency

For Maven users, add the dependency to your project's POM:

```
<dependency>
  <groupId>com.cobo.waas2</groupId>
  <artifactId>cobo-waas2</artifactId>
  <version>{VERSION}</version>
  <scope>compile</scope>
</dependency>
```

For Gradle users, add the dependency to your project's build file:

```
  repositories {
    mavenCentral()     // Fetch the dependency from Maven Central
  }

  dependencies {
     implementation "com.cobo.waas2:cobo-waas2:{VERSION}"
  }
```

<Note>Replace \{VERSION} with the lastest version number, for example, `1.2.0`. Obtain the latest version number from the [GitHub repository](https://github.com/CoboGlobal/cobo-waas2-java-sdk/tags).</Note>

## Configure API key and HTTP host

1. Set the API secret.

```java theme={null}
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setPrivKey("<YOUR_API_SECRET_IN_HEX>");
```

2. Select which [environment](/v2/guides/overview/environments) you want to use. The SDK uses the production environment by default.

```java theme={null}
// Select the development environment
defaultClient.setEnv(Env.DEV);

// Select the production environment
defaultClient.setEnv(Env.PROD);
```

## Code samples

For operation-specific documentation and sample code, see the [docs](https://github.com/CoboGlobal/cobo-waas2-java-sdk/tree/master/docs) folder in the WaaS SDK GitHub repository.

### List supported chains

```java theme={null}
// Import classes 
import com.cobo.waas2.ApiClient;
import com.cobo.waas2.ApiException;
import com.cobo.waas2.Configuration;
import com.cobo.waas2.Env;
import com.cobo.waas2.model.*;
import com.cobo.waas2.api.WalletsApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    // Use the development environment 
    defaultClient.setEnv(Env.DEV);
    // Set the API secret
    defaultClient.setPrivKey("<YOUR_API_SECRET_IN_HEX>");
    WalletsApi apiInstance = new WalletsApi();
    WalletType walletType = WalletType.fromValue("Custodial");
    WalletSubtype walletSubtype = WalletSubtype.fromValue("Asset");
    String chainIds = "";
    Integer limit = 10;
    String before = "";
    String after = "";
    try {
      // List supported chains
      ListSupportedChains200Response result = apiInstance.listSupportedChains(walletType, walletSubtype, chainIds, limit, before, after);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling WalletsApi#listSupportedChains");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

### Create a wallet

```java theme={null}
// Import classes 

import com.cobo.waas2.ApiClient;
import com.cobo.waas2.ApiException;
import com.cobo.waas2.Configuration;
import com.cobo.waas2.Env;
import com.cobo.waas2.model.*;
import com.cobo.waas2.api.WalletsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Use the development environment 
        defaultClient.setEnv(Env.DEV);
        // Set the API secret
        defaultClient.setPrivKey("<YOUR_API_SECRET_IN_HEX>");
        WalletsApi apiInstance = new WalletsApi();
        CreateWalletParams createWalletParams = new CreateWalletParams(
                new CreateCustodialWalletParams()
                        .name("Example Wallet")
                        .walletType(WalletType.CUSTODIAL)
                        .walletSubtype(WalletSubtype.ASSET)
        );
        try {
            // Create a Custodial Wallet
            CreatedWalletInfo result = apiInstance.createWallet(createWalletParams);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling WalletsApi#createWallet");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
```
