A standard java project has no awareness of aspects. You have two options:

- use the context menu on the Java project to add the aspectj nature. This
replaces the java builder for the project with the aspectj builder. You can
then set (in the project properties) the aspect path and point it at your
jar. Then when the project is built the aspects will be applied to the
contents.

- Run the java code with load time weaving. This involves modifying the
launch configuration to use
-javaagent:<pathtoaspectj>/lib/aspectjweaver.jar and ensuring that the
aspect jar was built with -outxml specified, so that the jar will contain
an aop*.xml file that lists the aspect.  When your application runs the
aspectjweaver code will attach a weaver to the class loader loading your
app. That weaver will search for aop xml files to find aspects and then
load up any aspects it finds and apply them to any code the associated
loader loads (i.e. your application).  There might be a context menu RunAs
shortcut for launching with load time weaving, I don't quite recall.

Andy

On 13 October 2014 10:00, mufc_fan <[email protected]> wrote:

> Hi Andy
>
>    Thank u...I have created aspect aj file for a java class file and then I
> exported it as a jar file and I imported it in another Aspectj project and
> called the function for which the advice had written and it runs normally.
> But when I import it in java project, the advice never runs when the
> function for which the advice is written...can u tell me why?
>
>
>
> --
> View this message in context:
> http://aspectj.2085585.n4.nabble.com/Aspectj-in-weaving-a-jar-file-tp4651584p4651593.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to