Starting a Java agent after program start

Paul Keeble picture Paul Keeble · Aug 14, 2009 · Viewed 18k times · Source

Is it possible to insert a javaagent after virtual machine start from within the same VM?

Lets say for example we have an agent in a jar myagent.jar with the appropriate meta data set-up and an agentmain method already implemented. Now the users program calls an API call which should result in the insertion of the agent so that it can redefine the classes.

Can it be done and how?

Answer

Alan Cabrera picture Alan Cabrera · Dec 18, 2010