The ACJ command is a compiler for compiling Java files and AJ files, equivalent to the Eclipse compiler (ECJ) +ASPECTJ Runtime extension
The AJ5 command uses-javaagent:pathto/aspectjweaver.jar to load the ASPECTJ program on jdk1.5 to modify the bytecode.
These two commands can be replaced with Java commands and Javac, and our command for the above article is an example
Load-time Weaving (LTW) weaving at load time
Compile
Ajc-outjar Myjar.jar helloworld.javaajc-outjar myaspect.jar-outxml myaspect.aj-classpath "myjar.jar;%CLASSPATH%"
Run
Aj5-classpath "myaspect.jar;myjar.jar;%classpath%" HelloWorld
Command translation
If the Aspectjrt.jar has been set in the CLASSPATH environment variable,%aspectj_home%\lib\aspectjrt.jar can be omitted in-classpath;
Compile
Javac Helloworld.javajar cvf myjar.jar helloworld.classjava-classpath "myjar.jar;%aspectj_home%\lib\aspectjrt.jar;% aspectj_home%\lib\aspectjtools.jar;%classpath% "Org.aspectj.tools.ajc.main-outxml Myaspect.aj-outjar MyAspect.jar
Run
Java-javaagent:%aspectj_home%\lib\aspectjweaver.jar-classpath "Myaspect.jar;myjar.jar;%aspectj_home%\lib\ aspectjrt.jar;%classpath% "HelloWorld
Compile-time Weaving compile-time weaving
Compile
Ajc-outjar Mytarget.jar Helloworld.java Myaspect.aj
Run
Aj5-classpath "mytarget.jar;%classpath%" HelloWorld
Command translation
Compile
Java-classpath "myjar.jar;%aspectj_home%\lib\aspectjrt.jar;%aspectj_home%\lib\aspectjtools.jar;%classpath%" Org.aspectj.tools.ajc.main-outjar Mytarget.jar Helloworld.java Myaspect.aj
Run
Java-classpath "mytarget.jar;%aspectj_home%\lib\aspectjrt.jar;%classpath%" HelloWorld
Post-compile Weaving after the compile-time weaving
Compile
Ajc-outjar Myjar.jar helloworld.javaajc-inpath Myjar.jar Myaspect.aj-outjar Mytarget.jar
Run
Aj5-classpath "mytarget.jar;%classpath%" HelloWorld
Command translation
Compile
Javac Helloworld.javajar cvf myjar.jar helloworld.classjava-classpath "myjar.jar;%aspectj_home%\lib\aspectjrt.jar;% aspectj_home%\lib\aspectjtools.jar;%classpath% "Org.aspectj.tools.ajc.main-inpath Myjar.jar Myaspect.aj-outjar Mytarget.jar
Run
Java-classpath "mytarget.jar;%aspectj_home%\lib\aspectjrt.jar;%classpath%" HelloWorld
The advantage of translating into Java commands is that you can weave directly to specify multiple -javaagent at Load-time weaving (LTW) load
Such as
JAVA-JAVAAGENT:ASPECTJWEAVER.JAR-JAVAAGENT:ZKMAGENT.JAR-CP Tracing.jar; Zkm.jar Com.zelix.ZKM
AJC and AJ5 commands for the aspectj of Java Reverse Foundation