You use the org.eclipse.ui.handlers
extension point to define a handler for the command id.
<extension
point="org.eclipse.ui.handlers">
<handler
class="org.eclipse.ui.examples.contributions.handlers.GlobalMenuHandler"
commandId="org.eclipse.ui.examples.contributions.commands.globalCommand">
</handler>
</extension>
You must also use the org.eclipse.ui.commands
extension point to define the command id in the first place. You can specify a default handler in the command id definition:
<extension
point="org.eclipse.ui.handlers">
<command
categoryId="org.eclipse.ui.examples.contributions.commands.category"
defaultHandler="org.eclipse.ui.examples.contributions.handlers.GlobalMenuHandler"
id="org.eclipse.ui.examples.contributions.commands.globalCommand"
name="%contributions.commands.globalCommand.name">
</command>
</extension>
(above examples are from the Eclipse help).
There is also this tutorial on commands.