Home > Back-end >  C the priming Javaagent dynamic libraries
C the priming Javaagent dynamic libraries

Time:10-02

1. He had written in c + + a Javaagent. DLL dynamic library, using JAVA program triggered dynamic DLL is successful, the JAVA code snippet below:
//the attach to the target VM
VirtualMachine vm=VirtualMachine. Attach (" 2177 ");

//get the system properties in target VM
The Properties props=vm. GetSystemProperties ();

//the construct the path to management agent
String home=props. GetProperty (" Java. Home ");
String agent=home + File. The separator + "lib" + File. The separator
+ "management - agent. The jar";

//the load agent into the target VM
Vm. LoadAgent (agent, "com. Sun. Management jmxremote. Port=5000");

//detach
Vm. Detach ();
2. The hope is that c + + code, direct call API to realize the above JAVA code function, and can call the function method,

Reference:
http://ifeve.com/jvm-attach/
  • Related