{
  "id": "execute",
  "title": "Execute",
  "url": "https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/gears-v1/jvm/classes/gearsbuilder/execute/",
  "summary": "Runs a Redis command. A more flexible version of executeArray.",
  "tags": [
    "docs",
    "operate",
    "stack"
  ],
  "last_updated": "2026-04-22T11:55:45+02:00",
  "page_type": "content",
  "content_hash": "246ebffaabd42b5fd02e3375c9090588832ddb5a587196e6d56b5214333501f2",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "[code example]\n\nRuns a Redis command, similar to [`executeArray`](https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/gears-v1/jvm/classes/gearsbuilder/executeArray). However, the `execute` function is more flexible. Unlike `executeArray`, the list of string arguments does not have to be an explicit `String[]` object. It allows function calls like this: <nobr>`execute(\"SET\", \"key\", \"value\")`.</nobr>"
    },
    {
      "id": "parameters",
      "title": "Parameters",
      "role": "parameters",
      "text": "| Name | Type | Description |\n|------|------|-------------|\n| command | string | A Redis command |"
    },
    {
      "id": "returns",
      "title": "Returns",
      "role": "returns",
      "text": "Returns the command result. It could be a string or an array of strings, depending on the command."
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "Without `String[]`:\n\n[code example]\n\nWith `String[]`:\n\n[code example]"
    }
  ],
  "examples": [
    {
      "id": "overview-ex0",
      "language": "java",
      "code": "public static java.lang.Object execute​(java.lang.String... command)",
      "section_id": "overview"
    },
    {
      "id": "examples-ex0",
      "language": "java",
      "code": "GearsBuilder.execute(\"SET\", \"age:maximum\", \"100\");",
      "section_id": "examples"
    },
    {
      "id": "examples-ex1",
      "language": "java",
      "code": "GearsBuilder.execute(new String[]{\"SET\", \"age:maximum\", \"100\"});",
      "section_id": "examples"
    }
  ]
}
