{
  "schema_version": 2,
  "id": "develop/clients/jedis",
  "title": "Jedis guide (Java)",
  "url": "https://redis.io/docs/latest/develop/clients/jedis/",
  "summary": "Connect your Java application to a Redis database",
  "aliases": [
    "/develop/connect/clients/java/jedis",
    "/connect/clients/java/",
    "/connect/clients/jedis/",
    "/clients/jedis/",
    "/develop/clients/java",
    "/develop/connect/clients/java/",
    "/develop/clients/java/jedis/"
  ],
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-08T15:41:24+01:00",
  "children": [
    {
      "id": "develop/clients/jedis/connect",
      "summary": "Connect your Java application to a Redis database",
      "title": "Connect to the server",
      "url": "https://redis.io/docs/latest/develop/clients/jedis/connect/"
    },
    {
      "id": "develop/clients/jedis/amr",
      "summary": "Learn how to authenticate to an Azure Managed Redis (AMR) database",
      "title": "Connect to Azure Managed Redis",
      "url": "https://redis.io/docs/latest/develop/clients/jedis/amr/"
    },
    {
      "id": "develop/clients/jedis/queryjson",
      "summary": "Learn how to use Redis Search with JSON and hash documents.",
      "title": "Index and query documents",
      "url": "https://redis.io/docs/latest/develop/clients/jedis/queryjson/"
    },
    {
      "id": "develop/clients/jedis/vecsearch",
      "summary": "Learn how to index and query vector embeddings with Redis",
      "title": "Index and query vectors",
      "url": "https://redis.io/docs/latest/develop/clients/jedis/vecsearch/"
    },
    {
      "id": "develop/clients/jedis/vecsets",
      "summary": "Index and query embeddings with Redis vector sets",
      "title": "Vector set embeddings",
      "url": "https://redis.io/docs/latest/develop/clients/jedis/vecsets/"
    },
    {
      "id": "develop/clients/jedis/transpipe",
      "summary": "Learn how to use Redis pipelines and transactions",
      "title": "Pipelines and transactions",
      "url": "https://redis.io/docs/latest/develop/clients/jedis/transpipe/"
    },
    {
      "id": "develop/clients/jedis/prob",
      "summary": "Learn how to use approximate calculations with Redis.",
      "title": "Probabilistic data types",
      "url": "https://redis.io/docs/latest/develop/clients/jedis/prob/"
    },
    {
      "id": "develop/clients/jedis/error-handling",
      "summary": "Learn how to handle errors when using Jedis.",
      "title": "Error handling",
      "url": "https://redis.io/docs/latest/develop/clients/jedis/error-handling/"
    },
    {
      "id": "develop/clients/jedis/failover",
      "summary": "Improve reliability using the failover features of Jedis.",
      "title": "Client-side geographic failover",
      "url": "https://redis.io/docs/latest/develop/clients/jedis/failover/"
    },
    {
      "id": "develop/clients/jedis/produsage",
      "summary": "Get your Jedis app ready for production",
      "title": "Production usage",
      "url": "https://redis.io/docs/latest/develop/clients/jedis/produsage/"
    }
  ],
  "page_type": "content",
  "content_hash": "cfd456049ddbb7d4b5ec94a43df955f98cded65ac8443b1aefeb9371283cdba1",
  "sections": [
    {
      "id": "install",
      "title": "Install",
      "role": "setup",
      "text": "To include `Jedis` as a dependency in your application, edit the dependency file, as follows.\n\n* If you use **Maven**:   \n\n  [code example]\n\n* If you use **Gradle**: \n\n  [code example]\n\n* If you use the JAR files, download the latest Jedis and Apache Commons Pool2 JAR files from [Maven Central](https://central.sonatype.com/) or any other Maven repository.\n\n* Build from [source](https://github.com/redis/jedis)"
    },
    {
      "id": "connect-and-test",
      "title": "Connect and test",
      "role": "content",
      "text": "Add the following imports to your source file:\n\nFoundational: Import required Jedis classes for Redis client functionality\n\n**Difficulty:** Beginner\n\n**Available in:** Java (Synchronous - Jedis)\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n\n\nConnect to localhost on port 6379:\n\nFoundational: Connect to a Redis server and establish a client connection\n\n**Difficulty:** Beginner\n\n**Available in:** Java (Synchronous - Jedis)\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n\n\nAfter you have connected, you can check the connection by storing and\nretrieving a simple [string](https://redis.io/docs/latest/develop/data-types/strings) value:\n\nFoundational: Set and retrieve string values using SET and GET commands\n\n**Difficulty:** Beginner\n\n**Available in:** Java (Synchronous - Jedis)\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n\n\nStore and retrieve a [hash](https://redis.io/docs/latest/develop/data-types/hashes):\n\nFoundational: Store and retrieve hash data structures using HSET and HGETALL\n\n**Difficulty:** Beginner\n\n**Available in:** Java (Synchronous - Jedis)\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n\n\nClose the connection when you're done:\n\nFoundational: Properly close a Redis client connection to release resources\n\n**Difficulty:** Beginner\n\n**Available in:** Java (Synchronous - Jedis)\n\n##### Java (Synchronous - Jedis)\n\n[code example]"
    },
    {
      "id": "more-information",
      "title": "More information",
      "role": "content",
      "text": "`Jedis` has a complete [API reference](https://www.javadoc.io/doc/redis.clients/jedis/latest/index.html) available on [javadoc.io/](https://javadoc.io/).\nThe `Jedis` [GitHub repository](https://github.com/redis/jedis) also has useful docs\nand examples including a page about handling\n[failover with Jedis](https://github.com/redis/jedis/blob/master/docs/failover.md)\n\nSee also the other pages in this section for more information and examples:"
    }
  ],
  "examples": [
    {
      "id": "install-ex0",
      "language": "xml",
      "code": "<dependency>\n      <groupId>redis.clients</groupId>\n      <artifactId>jedis</artifactId>\n      <version>7.2.0</version>\n  </dependency>",
      "section_id": "install"
    },
    {
      "id": "install-ex1",
      "language": "plaintext",
      "code": "repositories {\n      mavenCentral()\n  }\n  //...\n  dependencies {\n      implementation 'redis.clients:jedis:7.2.0'\n      //...\n  }",
      "section_id": "install"
    },
    {
      "id": "connect-and-test-ex0",
      "language": "java",
      "code": "import redis.clients.jedis.RedisClient;\nimport java.util.HashMap;\nimport java.util.Map;",
      "section_id": "connect-and-test"
    },
    {
      "id": "connect-and-test-ex1",
      "language": "java",
      "code": "RedisClient jedis = RedisClient.create(\"redis://localhost:6379\");",
      "section_id": "connect-and-test"
    },
    {
      "id": "connect-and-test-ex2",
      "language": "java",
      "code": "String res1 = jedis.set(\"bike:1\", \"Deimos\");\n        System.out.println(res1); // >>> OK\n\n        String res2 = jedis.get(\"bike:1\");\n        System.out.println(res2); // >>> Deimos",
      "section_id": "connect-and-test"
    },
    {
      "id": "connect-and-test-ex3",
      "language": "java",
      "code": "Map<String, String> hash = new HashMap<>();\n        hash.put(\"name\", \"John\");\n        hash.put(\"surname\", \"Smith\");\n        hash.put(\"company\", \"Redis\");\n        hash.put(\"age\", \"29\");\n\n        Long res3 = jedis.hset(\"user-session:123\", hash);\n        System.out.println(res3); // >>> 4\n\n        Map<String, String> res4 = jedis.hgetAll(\"user-session:123\");\n        System.out.println(res4);\n        // >>> {name=John, surname=Smith, company=Redis, age=29}",
      "section_id": "connect-and-test"
    },
    {
      "id": "connect-and-test-ex4",
      "language": "java",
      "code": "jedis.close();",
      "section_id": "connect-and-test"
    }
  ]
}
