Created
January 31, 2016 19:00
-
-
Save apangin/90950b6b9a25fbdebf63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.sun.tools.attach.VirtualMachine; | |
import java.nio.file.Paths; | |
public class InjectAgent { | |
public static void main(String[] args) throws Exception { | |
String PID = args[0]; | |
String agentJar = Paths.get("retransformer.jar").toAbsolutePath().toString(); | |
VirtualMachine vm = VirtualMachine.attach(PID); | |
try { | |
vm.loadAgent(agentJar); | |
} finally { | |
vm.detach(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment