# Creating a nested aspect

You can create aspects that are enclosed in other types (that is, nested aspects).

1. Open the New Aspect wizard.
2. Edit the Source Folder field to indicate in which folder you want the new aspect to reside. You can either type a path or click Browse to find the folder. If a folder is found for the current selection, that folder appears in the Source Folder field as the container for the new aspect.
3. Select the Enclosing Type check box and type the name of the enclosing type in the Enclosing Type field. You can also click Browse to select the enclosing type for the new aspect.
4. In the Name field, type a name for the new aspect.
5. Select the desired modifiers by using the Modifiers radio buttons and check boxes. Note that static should not be de-selected because nested aspects must be static.
6. In the Supertype field, type or click Browse to select a superclass/aspect for the new aspect.
7. Click the Add button to add interfaces for the new aspect to implement.
8. If you want to create a main method stub in the new aspect:
9. - Select the public static void main(String[] args) check box if you want the wizard to add the main method to the new aspect, thus making it a starting point of an application.
10. Optionally, select the Inherited abstract pointcuts box if you have overridden an abstract aspect and want the wizard to generate stubs for the abstract pointcuts.
11. Optionally, select the Generate comments box if you want the wizard to generate comments, as configured in the properties for the project.
12. Click Finish when you are done.
13. If the enclosing type is a class, you may wish to change the file extension in order to avoid errors in the editor and to have the AspectJ content correctly displayed in views such as the Outline view and the Package Explorer. Right click on the file in the package explorer then select Convert file extension to .aj.

Note: The new aspect is created in the same compilation unit as its enclosing type.

AspectJ projects
Aspects

Creating a new aspect
Creating a top-level aspect
Converting file extensions