bukkit register commands

Java
public class main {
  @Override
  public void onEnable() {
      this.getCommand("heal").setExecuter(new health(this));
      //E.g a heal command in class health
      // this.getCommand("heal").setExecture(new health(this))

      //If command in main class replace new <class>() with this.
      // this.getCommand("heal").setExecuter(this)
  }
}

//If in external class a constructor has to be made.
public class health {
  private main plugin;
  //Have to create constructor in external class
  public health(main plugin) { this.plugin = plugin; }  
  
  public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args) { 
  	//Do stuff
  }
  
}
Source

Also in Java: