# How to get command return value(s) when using Java bindings?

**URL:** <https://forum.canton.network/t/how-to-get-command-return-value-s-when-using-java-bindings/3879>\
**Category:** App Development\
**Tags:** daml, java, ledger-api\
**Created:** [February 9, 2022, 2:04pm UTC](https://forum.canton.network/t/how-to-get-command-return-value-s-when-using-java-bindings/3879 "2022-02-09T14:04:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon\_Alexe](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@Simon\_Alexe](https://forum.canton.network/u/Simon_Alexe)\
**Post date:** [February 9, 2022, 2:04pm UTC](https://forum.canton.network/t/how-to-get-command-return-value-s-when-using-java-bindings/3879/1 "2022-02-09T14:04:39Z")

</div>

Hello daml forum,

I am submitting commands on contracts in the daml ledger, as a certain party.

For this purpose, I use [CommandClient](https://docs.daml.com/0.13.34/app-dev/bindings-java/javadocs/com/daml/ledger/rxjava/CommandClient.html), that proposes 4 return choices : Empty, Transaction, TransactionId (String) and TransactionTree.

I tried them all and couldn’t find what I was looking for. What I want is the **return value(s) of the command**, as seen in the .daml code, example:

```haskell
template SomeTemplate
  with
    someField: Text
 (...)
 where
  controller consumer can
      DoThis : **value(s) returned**

```

How can I do that from java reactive bindings?

Thank you in advance

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [February 9, 2022, 2:09pm UTC](https://forum.canton.network/t/how-to-get-command-return-value-s-when-using-java-bindings/3879/2 "2022-02-09T14:09:21Z")

</div>

There is no method that _only_ provides you with the return value of the choice you are exercising. However, the transaction tree (and only that) contains the result value in the [`ExercisedEvent`](https://docs.daml.com/1.18.1/app-dev/bindings-java/javadocs/com/daml/ledger/javaapi/data/ExercisedEvent.html#getExerciseResult--).

In the simple case where you are only submitting a single exercise command, the [root events](https://docs.daml.com/1.18.1/app-dev/bindings-java/javadocs/com/daml/ledger/javaapi/data/TransactionTree.html#getRootEventIds--) will be a singleton list and contain the id of the exercise event you are looking for.

---

<div class="post-metadata">

**Author:** ![Simon\_Alexe](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@Simon\_Alexe](https://forum.canton.network/u/Simon_Alexe)\
**Post date:** [February 9, 2022, 2:15pm UTC](https://forum.canton.network/t/how-to-get-command-return-value-s-when-using-java-bindings/3879/3 "2022-02-09T14:15:05Z")

</div>

Thank you very much for such a rapid (instantaneous?) and exhaustive response.

I totally missed that ExercisedEvent.exerciseResult when looking at the transaction tree and this is exactly what I was looking for.
