# java-sdk
**Repository Path**: mirrors_erosb/java-sdk
## Basic Information
- **Project Name**: java-sdk
- **Description**: Java SDK for ConfigCat. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-09-24
- **Last Updated**: 2026-04-26
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# ConfigCat SDK for Java
https://configcat.com
ConfigCat SDK for Java provides easy integration for your application to ConfigCat.
ConfigCat is a feature flag and configuration management service that lets you separate releases from deployments. You can turn your features ON/OFF using ConfigCat Dashboard even after they are deployed. ConfigCat lets you target specific groups of users based on region, email or any other custom user attribute.
ConfigCat is a hosted feature flag service. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
[](https://travis-ci.com/configcat/java-sdk)
[](https://maven-badges.herokuapp.com/maven-central/com.configcat/configcat-java-client)
[](https://codecov.io/gh/ConfigCat/java-sdk)
[](http://javadoc.io/doc/com.configcat/configcat-java-client)

## Getting started
### 1. Install the package
*Maven:*
```xml
com.configcat
configcat-java-client
[4.0.1,)
```
*Gradle:*
```groovy
compile group: 'com.configcat', name: 'configcat-java-client', version: '4.+'
```
### 2. Go to Connect your application tab to get your *API Key*:

### 3. Import *com.configcat.** to your application
```java
import com.configcat.*;
```
### 4. Create the *ConfigCat* client instance
```java
ConfigCatClient client = new ConfigCatClient("#YOUR-API-KEY#");
```
### 5. Get your setting value:
```java
boolean isMyAwesomeFeatureEnabled = client.getValue(Boolean.class, "isMyAwesomeFeatureEnabled", false);
if(isMyAwesomeFeatureEnabled) {
doTheNewThing();
} else{
doTheOldThing();
}
```
Or use the async APIs:
```java
client.getValueAsync(Boolean.class, "isMyAwesomeFeatureEnabled", false)
.thenAccept(isMyAwesomeFeatureEnabled -> {
if(isMyAwesomeFeatureEnabled) {
doTheNewThing();
} else{
doTheOldThing();
}
});
```
## Getting user specific setting values with Targeting
Using this feature, you will be able to get different setting values for different users in your application by passing a `User Object` to the `getValue()` function.
Read more about [Targeting here](https://configcat.com/docs/advanced/targeting/).
## User object
Percentage and targeted rollouts are calculated by the user object you can optionally pass to the configuration requests.
The user object must be created with a **mandatory** identifier parameter which should uniquely identify each user:
```java
User user = User.newBuilder()
.build("#USER-IDENTIFIER#"); // mandatory
boolean isMyAwesomeFeatureEnabled = client.getValue(Boolean.class, "isMyAwesomeFeatureEnabled", user, false);
if(isMyAwesomeFeatureEnabled) {
doTheNewThing();
} else{
doTheOldThing();
}
```
## Sample/Demo app
* [Sample Console App](https://github.com/ConfigCat/java-sdk/tree/master/samples/console)
* [Sample Web app](https://github.com/ConfigCat/java-sdk/tree/master/samples/web)
## Polling Modes
The ConfigCat SDK supports 3 different polling mechanisms to acquire the setting values from ConfigCat. After latest setting values are downloaded, they are stored in the internal cache then all requests are served from there. Read more about Polling Modes and how to use them at [ConfigCat Java Docs](https://configcat.com/docs/sdk-reference/java/) or [ConfigCat Android Docs](https://configcat.com/docs/sdk-reference/android/).
## Support
If you need help how to use this SDK feel free to to contact the ConfigCat Staff on https://configcat.com. We're happy to help.
## Contributing
Contributions are welcome.
## About ConfigCat
- [Official ConfigCat SDKs for other platforms](https://github.com/configcat)
- [Documentation](https://configcat.com/docs)
- [Blog](https://configcat.com/blog)