You have two options if it comes to java activity:
1. provide on runtime an instance which shall be used to invoke defined method
<java name="shake hand" expr="#{hand}" method="shake" var="hand">
<transition to="wait" />
</java>
this will result in following code being executed: #{hand.shake()}
2. provide a class and method to be invoked that accepts argument given on runtime
<java name="shake \class="my.class.name" hand" method="shake" var="hand">
<arg><object expr="#{hand}"/></arg>
<transition to="wait" />
</java>
this will result in execution of my.class.name.shake(MyObject hand).
For more details about java activity plase take a look at user guide.
HTH