I have a java application that must run with jdk 1.5. I need a way to attach to this application JVM using its PID. I tried ByteBuddy library but it is giving me the following error when trying to load the agent.
Exception in thread "main" java.lang.IllegalStateException: Target could not dispatch command successfully
at net.bytebuddy.agent.VirtualMachine$ForHotSpot$Connection$ForJnaWindowsNamedPipe.execute(VirtualMachine.java:1043)
at net.bytebuddy.agent.VirtualMachine$ForHotSpot.load(VirtualMachine.java:361)
at net.bytebuddy.agent.VirtualMachine$ForHotSpot.loadAgent(VirtualMachine.java:335)
at main.Agent.main(Agent.java:28)
Here's the code in the main method:
public static void main(String[] args) {
try {
VirtualMachine vm = VirtualMachine.ForHotSpot.attach("19708");
vm.loadAgent("Agent.jar");
vm.detach();
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
Can anyone help me with this issue?