Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] startUp problem


I'm guessing from your output that you wanted to run the "MannersAspect" program. First off, you'll need to define a main method as an entry point, for example:

//MannersAspect.java
public aspect MannersAspect
{
      public static void main(String[] args) {
          HelloWorld hello=new HelloWorld();
        hello.say("Hi");
               hello.sayToPerson("Hi", "Hinna");
       }
   
         pointcut callSayMessage() : call(public static void HelloWorld.say*(..));
         before() : callSayMessage()
         {
             System.out.println("GoodDay!");
         }
         after(): callSayMessage()
         {
             System.out.println("Thankyou!");
         }
}


Then compile the two source files with "ajc MannersAspect.java HelloWorld.java", and run with "java MannersAspect". The program should produce the following output:

GoodDay!
Hi
Thankyou!
GoodDay!
Hinna, Hi
Thankyou!

-- Adrian
Adrian_Colyer@xxxxxxxxxx



"Hinna Javaid" <02030010@xxxxxxxxxxx>
Sent by: aspectj-users-admin@xxxxxxxxxxx

18/12/2003 11:10
Please respond to aspectj-users

       
        To:        <aspectj-users@xxxxxxxxxxx>
        cc:        
        Subject:        [aspectj-users] startUp problem



Hi

I am trying to write a simple helloworld program as my first AOP program. However, I keep on getting linking errors. There is no classpath error because the samples that come with aspectJ run successfully. I have taken the code from "I want my AOP-2" tutorial. as it says I have defined an aspect, and a class helloworld.

//MannersAspect.java
public aspect MannersAspect
{
   HelloWorld hello=new HelloWorld();
   
        pointcut callSayMessage() : call(public static void HelloWorld.say*(..));
        before() : callSayMessage()
        {
            System.out.println("GoodDay!");
        }
        after(): callSayMessage()
        {
            System.out.println("Thankyou!");
        }
}

//HelloWorld.java
public class HelloWorld
{
  public static void say(String message)
  {
      System.out.println(message);
  }

  public static void sayToPerson(String message, String name)
  {
    System.out.println(name+ ", "+ message);
  }


}
It compiles fine. It gives me an error when I try to run the program saying
"MannersAspect.java": 'class' or 'interface' expected


Please I will be ever so grateful if anyone of you could help me out. Please I really need help, and I don't have much time left as my deadline is approaching real fast. I am sure that you guys can easily help me out, as you must have gone through these initial startup phases as well.

thankyou so much
Hinna


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top