> For the complete documentation index, see [llms.txt](https://fredhopper.gitbook.io/product-discovery/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fredhopper.gitbook.io/product-discovery/a-b-testing-for-fhr/integration-steps-for-a-caching-solution/java-sdk-integration/setup.md).

# Setup

## **Installation**

Our **SDK** is free to use and it's available as a package on **Maven** **Central** repository. You can add it to your project easily through either **Maven** or **Gradle.**

### **Maven**

```markup
<dependencies>
...
        <dependency>
            <groupId>com.attraqt</groupId>
            <artifactId>sdk-fhr-ab-testing</artifactId>
            <version>1.0.0</version>
        </dependency>
...
</dependencies>
```

### Gradle

```javascript
dependencies {
    implementation 'sdk-fhr-ab-testing:1.0.0'
}
```

{% hint style="info" %}
**Important!** Make sure you include the latest version for the most up to date features and functionality.
{% endhint %}

## Initialization

### Standard

In order to be able to initialize your **SDK** you will need the following:

* **url -** the base **URL** for getting the running **A/B tests** provided by the technical consultant (without the path **/config/running/ab-tests**).
* **username** and **password** - the Basic Authentication credentials you normally use for all your **FHR** queries.

To initialize the **SDK** in your Java code you can look at the following snippet.

```java
 import com.attraqt.sdk.fhr.abtesting.AbTesting

...

AbTesting abTesting = AbTesting.builder()
                               .abTestsServerUrl("url")
                               .username("username")
                               .password("password")       
                               .build();

abTesting.start();
```

This is the most basic initialization you can do. The call to `start()` at the end, starts the **retrieval** of **running A/B tests** on a periodic basis of 5 minutes by default, storing the response in the mean time.

This should be enough for most use cases. However, the **SDK** offers a bit more customization.

### Custom

Apart from the mandatory **url, username** and **password**, you can also supply the following details:

* **cacheExpireTimeMinutes** - **Integer** - the **SDK** caches the **running A/B tests**, and you can control the time between refreshes. The **minimum** and also **default** expire time of the cache is **5** **minutes**. If you provide a number lower than **5**, the time will be set to **5**.
* **abTestsCache** - **AbTestsCache** **object** - Provide a custom implementation of the **AbTestCache** **object** to override the provided in-memory caching behavior.

  ***Only set if custom caching logic is required. Default implementation should be used as standard.***
* **runningAbTestsFetcher** - **RunningAbTests** **object** - Provide a custom implementation of the RunningAbTests object to override the provided ab-tests fetching behaviour.

  ***Only set if custom ab-tests fetching logic is required. Default implementation should be used as standard.***

For the **abTestsCache** and the **runningAbTestsFetcher**, you can check out the extension section.

{% content-ref url="/pages/4plxQXR6J9hHlyYk8rrd" %}
[Extending the SDK](/product-discovery/a-b-testing-for-fhr/integration-steps-for-a-caching-solution/java-sdk-integration/extending-the-sdk.md)
{% endcontent-ref %}

## Use

Once initialized you can check out the corresponding pages on each of the key functionalities available in the **SDK**. **\*\*These pages essentially cover a built-in implementation of what's covered in the** [**Overview**](https://github.com/Attraqt/product-discovery-documentation/blob/main/new-docs/a-b-testing/fhr-a-b-testing/integration-steps-for-a-caching-solution/java-sdk-integration/broken-reference/README.md)**. You can start with the first step -** Retrieve running A/B tests.\*\*

{% content-ref url="/pages/qI2OnEFnAu0CWmvHTdpy" %}
[Retrieve running A/B tests - Java SDK](/product-discovery/a-b-testing-for-fhr/integration-steps-for-a-caching-solution/java-sdk-integration/retrieve-running-a-b-tests-java-sdk.md)
{% endcontent-ref %}
