Creating your first AspectJ project

In this section you will create a new AspectJ project and add a package and a Java class to your project.

  1. Inside Eclipse select the menu item File > New > Project.... to open the New Project wizard.
  2. Select AspectJ Project then click Next. On the next page, type "Hello World" in the Project name field and click Finish.

    New AspectJ Project Wizard

    The Java perspective opens inside the workbench with the new AspectJ project in the Package Explorer.
  3. Select the "Hello World" project in the package explorer then select File > New > Package.... to open the New Java Package wizard. Type "helloworld" in the name field and click finish.
  4. Select the package that you just created in the package explorer then select File > New > Class.... to open the New Java Class wizard. Type "Hello" in the name field, select the option to allow Eclipse to create a main method and click finish.

    New Java Class Wizard

  5. Type the following into your new class.


    public static void main(String[] args) {
         sayHello();
    }

    public static void sayHello() {
         System.out.print("Hello");
    }

  6. Save the file.

Related concepts

AspectJ projects
AspectJ perspectives

Related tasks

Creating a new AspectJ project
Converting a Java project to an AspectJ project