通过pid,attach agent

public static void attach(String agentJar, String pid) {
     try {
      VirtualMachine vm = VirtualMachine.attach(pid);
      vm.loadAgent(agentJar);
      vm.detach();
    } catch (AttachNotSupportedException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (AgentLoadException e) {
      e.printStackTrace();
    } catch (AgentInitializationException e) {
      e.printStackTrace();
    }
  }

你可能感兴趣的:(pid,agent,Attach)