Launching a program with the main method in an aspect

The way to launch an AspectJ program where the main method is contained in an aspect is to use an AspectJ/Java Application launch configuration.

  1. In the Package Explorer, select the compilation unit or .aj file you want to launch.
  2. From the pop-up menu, select Run > AspectJ/Java Application. Alternatively, select Run > Run As > AspectJ/Java Application in the workbench menu bar, or select Run As > AspectJ/Java Application in the drop-down menu on the Run tool bar button
  3. Your program is now launched, and text output is shown in the Console.

You can also launch an AspectJ program with the main method in an aspect, by selecting a project instead of the compilation unit or .aj file. You will be prompted to select the aspect from those aspects and classes that define a main method.

Related tasks
Launching a program with the main method in a class
Launching a program with an aspectpath or an outjar
Load-time weaving
Debugging a program