title: Java - AttachNotSupportedException: Unable to open socket file: HotSpot VM not loaded
body: <p>When attempting to attach an agent jar file onto another process running in java, I have came across the exception:</p>
  
  <p><strong><em>com.sun.tools.attach.AttachNotSupportedException:</em></strong> 
  <em>Unable to open socket file: target process not responding or HotSpot VM not loaded</em></p>
  
  <p>I was running linux, with java <strong>Oracle JDK 8_101</strong>, however after answering this question I've realized the O.S does not matter for the cause of this problem. </p>
  
  <p><em>Edit:</em>
  <strong><em>Answer:</em></strong> </p>
  
  <p>If you encounter this problem, the reason it occured for me is because I was launching a program from a different JVM, other than the default JVM specified for the system. </p>
  
  <p>i.e) </p>
  
  <p><strong>Program</strong> <strong><em>A</em></strong> <strong><em>(The launcher)</em></strong>, is running on <strong>JVM-1</strong> <em>(JDK_8_1 for example, or JDK_8_1/jdk/jre)</em>.</p>
  
  <p><strong>Program</strong> <strong><em>A</em></strong> <strong><em>(The launcher)</em></strong>, creates a process with <strong><em>java -jar programB.jar</em></strong></p>
  
  <p><strong>Program</strong> <strong><em>B</em></strong> <strong><em>(The target)</em></strong>, is running on the system's default JVM, <strong>JVM-2</strong> <em>(JDK_8_2 for example, or JDK_8_2/jre)</em>.</p>
  
  <p><strong>Program</strong> <strong><em>A</em></strong> <strong><em>(The launcher)</em></strong> <strong>CANNOT</strong> attatch to 
  <strong>Program</strong> <strong><em>B</em></strong> <strong><em>(The target)</em></strong>, because the JVM <strong>Program</strong> <strong><em>A</em></strong> <strong><em>(The launcher)</em></strong> is running on, does not match the JVM of which <strong>Program</strong> <strong><em>B</em></strong> <strong><em>(The target)</em></strong> is running on, thus throwing the 
  <strong><em>com.sun.tools.attach.AttachNotSupportedException:</em></strong> </p>