开发者

Run a compiled program using ajc

开发者 https://www.devze.com 2023-03-07 21:07 出处:网络
I have written two simple codes..one java code to print a Hello World statement and other a aspect code to be weaven into it..

I have written two simple codes..one java code to print a Hello World statement and other a aspect code to be weaven into it..

My hello world code is

// HelloWorld.java
public class HelloWorld {
public static void main(String args[]){
   say("Hello world");

}
public static void say(String message) {
    S开发者_如何学JAVAystem.out.println(message);
}    
public static void sayToPerson(String message, String name) {
    System.out.println(name + ", " + message);
}
}

and my aspect code is..

public aspect MannersAspect {
pointcut callSayMessage() : call(public static void HelloWorld.say*(..));
before() : callSayMessage() {
    System.out.println("Good day!");
}
after() : callSayMessage() {
    System.out.println("Thank you!");
}
}

I have saved both into HelloWorld.java and MannersAspect.java and have compiled it using ajc *.java

It has given me two classes HelloWorld.class and MannersAspect.class

Now the major question for me is "HOW TO RUN IT"?

Please help me with this.I am stuck.Thanks in advance..


I figured It out..:P:P

I saw it on a website and it was like..

ajc -argfile <fullpath>\myList.lst

where myList.lst contained both files like this

HelloWorld.java
MannersAspect.java

And then doing java HelloWorld

Cheers

0

精彩评论

暂无评论...
验证码 换一张
取 消