Skip to content

Instantly share code, notes, and snippets.

@jesperfj
Created June 14, 2011 21:53
Show Gist options
  • Save jesperfj/1026008 to your computer and use it in GitHub Desktop.
Save jesperfj/1026008 to your computer and use it in GitHub Desktop.
Getting the Class-Path manifest attribute from the jar file that this class belongs to
java.util.jar.JarFile jar =
new java.util.jar.JarFile((thispackage.ThisClass.class.getProtectionDomain()
.getCodeSource().getLocation()).getFile());
System.out.println(jar.getManifest().getMainAttributes().getValue("Class-Path"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment