title: Location of javaagent jar in bootclasspath
body: <p>I have a javaagent jar that I put on the bootclasspath using </p>
  
  <pre><code>Boot-Class-Path: myagent.jar
  </code></pre>
  
  <p>inside the MANIFEST.MF file.</p>
  
  <p>I need to find out the directory on the filesystem in which the jar is located.</p>
  
  <p>However the method described for this <a href="https://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file">here</a> doesnt seem to work for me:</p>
  
  <pre><code> new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation().toURI().g­etPath());
  </code></pre>
  
  <p>In this case the ProtectionDomain.getCodeSource() returns null. I guess this is happening because the jar has been put on the boot classpath. Because of this I also cannot do MyClass.getClassLoader() to get the resource location.</p>
  
  <p>I am using Java 6.</p>
  
  <p>Can anyone tell how to get the location of the jar?</p>