{"id":19149858,"url":"https://github.com/harness/ff-java-server-sdk","last_synced_at":"2025-11-11T18:02:06.101Z","repository":{"id":37854094,"uuid":"342694070","full_name":"harness/ff-java-server-sdk","owner":"harness","description":"Java Server SDK for integrating with Harness Feature Flag service.","archived":false,"fork":false,"pushed_at":"2025-11-11T12:44:20.000Z","size":1201,"stargazers_count":6,"open_issues_count":3,"forks_count":22,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-11-11T14:26:44.482Z","etag":null,"topics":["cd","ci","feature-flags","java","sdk"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harness.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-02-26T20:32:33.000Z","updated_at":"2025-09-23T14:08:14.000Z","dependencies_parsed_at":"2023-11-28T11:24:37.559Z","dependency_job_id":"bac13bd4-ec11-468a-b3d1-27b5bb87b7f3","html_url":"https://github.com/harness/ff-java-server-sdk","commit_stats":null,"previous_names":["drone/ff-java-server-sdk"],"tags_count":55,"template":false,"template_full_name":null,"purl":"pkg:github/harness/ff-java-server-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fff-java-server-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fff-java-server-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fff-java-server-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fff-java-server-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harness","download_url":"https://codeload.github.com/harness/ff-java-server-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fff-java-server-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283900033,"owners_count":26913495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-11T02:00:06.610Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cd","ci","feature-flags","java","sdk"],"created_at":"2024-11-09T08:09:53.285Z","updated_at":"2025-11-11T18:02:06.053Z","avatar_url":"https://github.com/harness.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Java SDK For Harness Feature Flags\n========================\n\n## Table of Contents\n**[Intro](#Intro)**\u003cbr\u003e\n**[Requirements](#Requirements)**\u003cbr\u003e\n**[Quickstart](#Quickstart)**\u003cbr\u003e\n**[Further Reading](docs/further_reading.md)**\u003cbr\u003e\n\n\n## Intro\n\nUse this README to get started with our Feature Flags (FF) SDK for Java. This guide outlines the basics of getting started with the SDK and provides a full code sample for you to try out.\nThis sample doesn’t include configuration options, for in depth steps and configuring the SDK, for example, disabling streaming or using our Relay Proxy, see the  [Java SDK Reference](https://ngdocs.harness.io/article/i7et9ebkst-integrate-feature-flag-with-java-sdk).\n\nFor a sample FF Java SDK project, see our [test Java project](https://github.com/harness/ff-java-server-sdk/blob/main/examples/src/main/java/io/harness/ff/examples/GettingStarted.java).\n\n\n![FeatureFlags](https://github.com/harness/ff-java-server-sdk/raw/main/docs/images/ff-gui.png)\n\n## Requirements\n\nTo use this SDK, make sure you've:\n\n- Installed [JDK 8](https://openjdk.java.net/install/) or a newer version\u003cbr\u003e\n- Installed Maven or Gradle or an alternative build automation tool for your application\n\nTo follow along with our test code sample, make sure you’ve:\n- [Created a Feature Flag](https://ngdocs.harness.io/article/1j7pdkqh7j-create-a-feature-flag) on the Harness Platform called harnessappdemodarkmode\n- Created a [server SDK key](https://ngdocs.harness.io/article/1j7pdkqh7j-create-a-feature-flag#step_3_create_an_sdk_key) and made a copy of it\n\n### General Dependencies\n\n[Defined in the main project](./pom.xml)\n\n### Logging Dependencies\n\nLogback\n```pom\n\u003cdependency\u003e\n    \u003cgroupId\u003ech.qos.logback\u003c/groupId\u003e\n    \u003cartifactId\u003elogback-classic\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nLog4j\n```pom\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.apache.logging.log4j\u003c/groupId\u003e\n    \u003cartifactId\u003elog4j-api\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.apache.logging.log4j\u003c/groupId\u003e\n    \u003cartifactId\u003elog4j-core\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.apache.logging.log4j\u003c/groupId\u003e\n    \u003cartifactId\u003elog4j-slf4j-impl\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Install the SDK\n\nThe first step is to install the FF SDK as a dependency in your application using your application's dependency manager. You can use Maven, Gradle, SBT, etc. for your application.\n\nRefer to the [Harness Feature Flag Java Server SDK](https://mvnrepository.com/artifact/io.harness/ff-java-server-sdk) to identify the latest version for your build automation tool.\n\nThis section lists dependencies for Maven and Gradle:\n\n#### Maven\n\nAdd the following Maven dependency in your project's pom.xml file:\n```pom\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.harness\u003c/groupId\u003e\n    \u003cartifactId\u003eff-java-server-sdk\u003c/artifactId\u003e\n    \u003cversion\u003e1.8.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n#### Gradle\n\n```\nimplementation 'io.harness:ff-java-server-sdk:1.8.0'\n```\n\n### Code Sample\nHere is a complete example that will connect to the feature flag service and report the flag value every 10 seconds until the connection is closed.\nAny time a flag is toggled from the feature flag service you will receive the updated value.\n\nAfter installing the SDK, enter the SDK keys that you created for your environment. The SDK keys authorize your application to connect to the FF client.\n\n```java\npackage io.harness.ff.examples;\n\nimport io.harness.cf.client.api.*;\nimport io.harness.cf.client.dto.Target;\n\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.ScheduledExecutorService;\nimport java.util.concurrent.TimeUnit;\n\npublic class GettingStarted {\n    // API Key - set this as an env variable\n    private static String apiKey = getEnvOrDefault(\"FF_API_KEY\", \"\");\n\n    // Flag Identifier\n    private static String flagName = getEnvOrDefault(\"FF_FLAG_NAME\", \"harnessappdemodarkmode\");\n\n    private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);\n\n    public static void main(String[] args) {\n        System.out.println(\"Harness SDK Getting Started\");\n\n        // Create a Feature Flag Client\n        // try-with-resources is used here to automatically close the client when this block is exited\n        try (CfClient cfClient = new CfClient(apiKey)) {\n            cfClient.waitForInitialization();\n\n            // Create a target (different targets can get different results based on rules.  This includes a custom attribute 'location')\n            final Target target = Target.builder()\n                    .identifier(\"javasdk\")\n                    .name(\"JavaSDK\")\n                    .attribute(\"location\", \"emea\")\n                    .build();\n\n            // Loop forever reporting the state of the flag\n            scheduler.scheduleAtFixedRate(\n                    () -\u003e {\n                        boolean result = cfClient.boolVariation(flagName, target, false);\n                        System.out.println(\"Boolean variation is \" + result);\n                    },\n                    0,\n                    10,\n                    TimeUnit.SECONDS);\n\n            // SDK will exit after 15 minutes, this gives the example time to stream events\n            TimeUnit.MINUTES.sleep(15);\n\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n    }\n\n    // Get the value from the environment or return the default\n    private static String getEnvOrDefault(String key, String defaultValue) {\n        String value = System.getenv(key);\n        if (value == null || value.isEmpty()) {\n            return defaultValue;\n        }\n        return value;\n    }\n}\n```\n\n### Running the example\n\n```bash\nexport FF_API_KEY=\u003cyour key here\u003e\n\n./gradlew clean build\n./gradlew examples:GettingStarted --console=plain\n```\n\n### Running the example with Docker\nIf you don't have the right version of java installed locally, or don't want to install the dependencies you can\nuse docker to get started.\n\n```bash\n# Run the Example\ndocker run -e FF_API_KEY=$FF_API_KEY -v $(PWD):/app -v \"$HOME/.m2\":/root/.m2 -w /app gradle:8.5-jdk11 gradle clean build -xtest examples:GettingStarted --console=plain\n```\n\n\n### Additional Reading\n\nFurther examples and config options are in the further reading section:\n\n[Further Reading](docs/further_reading.md)\n\n[GraalVM](examples-graalvm-native/README.md)\n\n-------------------------\n[Harness](https://www.harness.io/) is a feature management platform that helps teams to build better software and to\ntest features quicker.\n\n-------------------------\n\n### Code Cleanup (Beta)\nThe java sdk supports automated code cleanup. For more info see the [docs](/examples/src/main/java/io/harness/ff/code_cleanup_examples/README.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharness%2Fff-java-server-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharness%2Fff-java-server-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharness%2Fff-java-server-sdk/lists"}