Search code examples
javaaspectjload-time-weaving

Specifying -javaagent in some other way


I am trying to get to the point where I can start my web application using:

java -jar application.jar

I have embedded Jetty and used a maven assembly to build the required jar and this all works perfectly, however I have just realised that I need LTW with AspectJ. Normally when the app is deployed in an appserver, -javaagent:aspectjweaver.jar is added to the appserver startup. I dont want the clean startup line of my app to turn into:

java -javaagent:aspectjweaver.jar -jar application.jar

So is there another way that I can initiate Aspectj LTW without resorting to this?


Solution

  • How about trying build time weaving with Aspectj instead, this way the only dependency at runtime will be the aspectjrt.jar file and will not require explicit -javaagent directive.