How to debug TWCore using Eclipse

Debugging in Eclipse is fairly easy and straightforward if you get the hang of it.

In a nutshell:

  1. Set a breakpoint somewhere in the code where you want to check the variables or to see the flow of the executing code.
  2. Switch to the debug perspective when the breakpoint is passed
  3. Examine the variables in the debug perspective
  4. Use the debug buttons (Step Into, Step Over, Step Out) to see the code that's being executed, line by line.


  • You need to start your program in debug mode to be able to debug it (else your breakpoints will be ignored).
  • When debugging a TWCore bot, it can time-out if you keep it suspended for too long. This is normal as any client need to keep sending packets to the server to make sure it's still alive. If you want to prevent this, you just have to resume your thread within a timely fashion after it's suspended on a breakpoint.


As an example, I will debug the following modified (and simplified) ultrabot as I need to know the value of the variable messagesCount on line 18 :

package twcore.bots.ultrabot;

import twcore.core.*;
import twcore.core.command.*;

public class ultrabot extends SubspaceBot {

    private int messagesCount;

    /** Creates a new instance of ultrabot */
    public ultrabot(BotAction botAction) {

    public void handleEvent(Message event) {
        if(messagesCount == 70) {

    public void handleEvent(LoggedOn event) {

... More to come :)

Last modified 11 years ago Last modified on Apr 17, 2008 1:22:29 PM