I’d like to learn something about javaagents, but researching is not easy. Most of result refers to JADE. I know java agent can mean two things:
- An agent programmed in Java being an incarnation of the agent
concept of distributed systems. - A low-level software component to augment the working of a JVM, such
as profilers, code-coverage tools, etc
I’ve found similar question here, but unfortunately it also refers to version 1.
Do you know any articles, tutorials for beginners, sample project about javaagent in version 2?
I’ve found one here, but I’m looking for more.
The second case talks about Java Instrumentation API – this link points to a Javadoc which is rather descriptive.
And here, is the full instruction and an example of how to create java instrumentation agent.
The main concept is to:
Implement a static
premain(as an analogy tomain) method, like this:Create a manifest file (say,
manifest.txt) marking this class for pre-main execution. Its contents are:Compile the class and package this class into a
JARarchive:Execute your JVM with
-javaagentparameter, like this: