# Execute tctl command via Java SDK

**URL:** <https://community.temporal.io/t/execute-tctl-command-via-java-sdk/6998>\
**Category:** Community Support\
**Tags:** java-sdk, tctl\
**Created:** [January 20, 2023, 6:11pm UTC](https://community.temporal.io/t/execute-tctl-command-via-java-sdk/6998 "2023-01-20T18:11:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkrch](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@jkrch](https://community.temporal.io/u/jkrch)\
**Post date:** [January 20, 2023, 6:11pm UTC](https://community.temporal.io/t/execute-tctl-command-via-java-sdk/6998/1 "2023-01-20T18:11:47Z")

</div>

I am trying to dynamically define search attributes via the Java SDK. After researching this, it seems like this is only possible via the CLI. That being the case, is there a way for tctl commands to be executed from the Java SDK?

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [January 21, 2023, 5:36pm UTC](https://community.temporal.io/t/execute-tctl-command-via-java-sdk/6998/2 "2023-01-21T17:36:07Z")

</div>

You don’t have to use tctl and can use Operator Service, for example:

```auto
OperatorServiceStubs operatorService = OperatorServiceStubs.newServiceStubs(
            OperatorServiceStubsOptions.newBuilder()
                    .setChannel(service.getRawChannel())
                    .validateAndBuildWithDefaults());
// ...
 operatorService.blockingStub().addSearchAttributes(AddSearchAttributesRequest.newBuilder()
                .putAllSearchAttributes(Collections.singletonMap("MySuperCustom", IndexedValueType.INDEXED_VALUE_TYPE_TEXT))
                .build());

```

Where “service” is your normal WorkflowService.

You can add multiple at a time. Just note it might take (believe up to 10s) for them to be registered with the cluster, can check with

`tctl cl gsa`

---

<div class="post-metadata">

**Author:** ![jkrch](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@jkrch](https://community.temporal.io/u/jkrch)\
**Post date:** [January 31, 2023, 10:20pm UTC](https://community.temporal.io/t/execute-tctl-command-via-java-sdk/6998/3 "2023-01-31T22:20:31Z")

</div>

Sorry for the delay. This worked perfectly. Thank you!
