How can I have a Java Agent start without the attach library?
Any way on starting an agent without the attach libary?
120 views Asked by AudioBubble At
2
There are 2 answers
0
On
You can use jattach which implements the important bits for Windows and Linux.
Attaching an agent can be done with:
jattach PID load instrument false /path/to/agent.jar`
You can add a Java agent when starting a program using the
-javaagent:./agent.jar=arg
command. The./agent.jar
is the location of the jar file containing the agent code. It is required to add a manifest containing an entryAgent-Premain
naming a class containing apremain
method.For a running agent, the tools.jar is required. As an exception, I implemented the attachment protocol for Unix systems for HotSpot in Byte Buddy.