title: error trying to attach to virtual machine
body: <p>I'm trying to attach to a running JVM to debug it using the Virtual Machine class in java. I'm currently have java 8, with jdk1.8.0_11. I have tried to add a manifest to it, with  but to no avail. I'm also importing the tools.jar file from my JDK\libs folder.</p>
  
  <p>My code:</p>
  
  <pre><code>import java.io.IOException;
  import java.util.List;
  
  import com.sun.tools.attach.AgentInitializationException;
  import com.sun.tools.attach.AgentLoadException;
  import com.sun.tools.attach.AttachNotSupportedException;
  import com.sun.tools.attach.VirtualMachine;
  import com.sun.tools.attach.VirtualMachineDescriptor;
  
  public class loadVM {
      public static void main(String[] args) {
          String name = "replaceAfterNameFound";
          List &lt;VirtualMachineDescriptor&gt; vms = VirtualMachine.list();
          for (VirtualMachineDescriptor vmd: vms) {
              System.out.println(vmd.displayName());
              if (vmd.displayName().equals(name)) {
                  try {
                      VirtualMachine vm = VirtualMachine.attach(vmd.id());
                      String agent = "";
                      vm.loadAgent(agent);
                  } catch(AttachNotSupportedException e) {
                      e.printStackTrace();
                  } catch(IOException e) {
                      e.printStackTrace();
                  } catch(AgentLoadException e) {
                      e.printStackTrace();
                  } catch(AgentInitializationException e) {
                      e.printStackTrace();
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>Here is a copy of the error I get when running it:</p>
  
  <blockquote>
    <p>java.util.ServiceConfigurationError:com.sun.tools.attach.spi.AttachProvider:
    Provider sun.tools.attach.WindowsAttachProvider could not be
    instantiated</p>
  </blockquote>
  
  <p>Thank you guys for all your help!</p>