I am new to aspectj and I have one doubt whether we can inject the code before the function that exists in the jar file using aspectj.
Yes, you can weave aspect code into third-party class files or JARs. There are two ways to achieve that:
-javaagent:pathto/aspectjweaver.jar
in order to achieve aspect weaving during classloading. This way you sacrifice some start-up time, but do not need to create a modified JAR file. Everything happens dynamically.And now please read some AspectJ documentation.