Guide · Open source
How to use Jedis: add the Java Redis client and run your first commands
Updated · written with AI from the project's own documentation and checked against our catalogue data
Jedis is an open-source Java library that lets your Java programs send commands to a Redis server. This guide shows you how to add it to a Maven project, start a local Redis server, connect and send a first command. It also covers cluster connections, the Redis data types it supports and where to find deeper documentation.
Quick start
- 1Add the dependency. Add the redis.clients jedis dependency to your pom.xml file.
- 2Start Redis. Run the Docker command to start a local Redis server on port 6379.
- 3Create a client. Build a RedisClient with hostAndPort set to localhost and 6379.
- 4Send a command. Call a method that maps to a Redis command, such as sadd, on the client.
- 5Connect to a cluster if needed. Use RedisClusterClient with a set of HostAndPort node addresses.
- 6Read the docs. Use the Jedis documentation site and Javadocs for failover, authentication and the full API.
What Jedis is and when to use it
Jedis is a Java client for Redis, a fast data store that is often used for caching and quick lookups. It is designed for performance and ease of use. You call methods in your Java code that map to Redis commands, and the library sends them to the server.
- Use Jedis if you need to read and write Redis data from a Java application.
- Use Jedis if your Java services connect to Redis Cluster.
- Look elsewhere if you want a high-level object mapping layer. The Jedis README points to redis-om-spring for that.
- Jedis is only the client. You still need a running Redis server.
What you need before you start
You need a Java JDK, a build tool such as Maven, and a running Redis server. The supported JDK versions depend on the Jedis version: the compatibility table in the README lists 8, 11, 17, 21 and, for the newest releases, 25.
- Java JDK (8, 11, 17, 21 or 25, depending on the Jedis version)
- Maven or another Java build tool
- A running Redis server. The README suggests Docker.
Add Jedis to your project
Jedis is distributed through Maven Central. If you use Maven, add the dependency to your pom.xml file. The README example uses version 8.0.1.
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>8.0.1</version>
</dependency>Start a Redis server and connect
The README suggests running Redis with Docker. Run the command below, then create a client that points to localhost on port 6379. The README example uses the RedisClient builder.
docker run -p 6379:6379 -it redis:latest
RedisClient jedis = RedisClient.builder().hostAndPort("localhost", 6379).build();
jedis.sadd("planets", "Venus");Connect to a Redis Cluster
To connect to a Redis Cluster, use RedisClusterClient instead of RedisClient. Pass it a set of cluster node addresses. The README says Jedis supports the Redis Cluster Specification. After connecting, you send commands the same way as with a standard connection.
Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7379));
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7380));
RedisClusterClient jedis = RedisClusterClient.builder().nodes(jedisClusterNodes).build();
jedis.sadd("planets", "Mars");Redis data types, failover and authentication
The README states that Jedis includes support for all Redis data types, along with features such as JSON and VectorSets. Jedis also supports retry and failover across more than one Redis deployment, so an application can move to the next available deployment if the current one becomes unavailable. Token-based authentication starts with release 5.3.0 GA, and the extension library includes built-in support for Microsoft EntraID.
- Failover details and options: the Jedis failover docs at redis.github.io/jedis/failover/
- Authentication details: the Advanced Usage page at redis.github.io/jedis/advanced-usage/
Where to find more examples and help
The Jedis documentation site and the latest Javadocs cover the API in detail. The redis.clients.jedis.examples package in the test source code has use-case examples. For questions, the README points to the Redis Discord server and Jedis GitHub Discussions. Bug reports go to the GitHub issue tracker.
What people use it for
- Caching or quick lookups from a Java web service backed by Redis
- Writing and reading set or other Redis data types from a Java application
- Connecting a Java service to a Redis Cluster
- Working with Redis JSON or VectorSets from Java code
Frequently asked questions
Is Jedis free to use?
Yes. The README states that Jedis is licensed under the MIT license. The license file is in the project's GitHub repository.
What do I need to run Jedis?
You need a Java JDK, a build tool such as Maven, and a running Redis server. The README lists JDK 8, 11, 17, 21 or 25 depending on the Jedis version.
How do I install Jedis?
If you use Maven, add the redis.clients jedis dependency to your pom.xml file. The README example uses version 8.0.1. Other build tools are also possible, but the README only shows Maven.
Does Jedis work with Redis Cluster?
Yes. The README says Jedis supports the Redis Cluster Specification. Use RedisClusterClient and pass it a set of node addresses.
What is the difference between Jedis and redis-om-spring?
Jedis is a client that sends Redis commands. The README says redis-om-spring is the option for a high-level object mapping layer. Choose Jedis for direct command access.
What are the alternatives to Jedis?
Comparable Java projects include Lettuce, Redisson and Spring Data Redis. This guide does not compare their features or performance.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Jedis suits Java developers who want a direct, performance-focused client for Redis, with Maven distribution and Javadocs. If you need object mapping, or you do not write Java, pick a different tool. You will also need your own Redis server, since Jedis does not include one.
Install options & downloads