LoadAgent.java如下 :
import java.io.IOException;
import com.sun.tools.attach.AgentInitializationException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;
/**
* @author z00174343
*
*/
public class LoadAgent {
/**
* @param args
*/
public static void main(String[] args) throws AttachNotSupportedException,IOException,AgentLoadException,AgentInitializationException {
// TODO Auto-generated method stub
VirtualMachine vm = VirtualMachine.attach(args[0]);
vm.loadAgent(args[1]);
}
}
抛出异常:
E:\wokspace\Demo1\src>java LoadAgent 4456 "E:\wokspace\Demo1\src\agent_fuckallbt
n.jar"
java.lang.UnsatisfiedLinkError: no attach in java.library.path
Exception in thread "main" com.sun.tools.attach.AttachNotSupportedException: no
providers installed
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:190)
at LoadAgent.main(LoadAgent.java:21)
注:我在其它电脑上就可以运行.