Skip to content

Instantly share code, notes, and snippets.

@sebasjm
Created March 8, 2011 22:35
Show Gist options
  • Select an option

  • Save sebasjm/861255 to your computer and use it in GitHub Desktop.

Select an option

Save sebasjm/861255 to your computer and use it in GitHub Desktop.
list java/lang public classes in a jar file
public static void main(String args[]) throws IOException, ClassNotFoundException {
JarFile jarFile = new JarFile("/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes/classes.jar");
Enumeration allEntries = jarFile.entries();
while (allEntries.hasMoreElements()) {
JarEntry entry = (JarEntry) allEntries.nextElement();
String name = entry.getName();
if (name.startsWith("java/lang") && !name.substring(10).contains("/") && !name.contains("$")) {
int value = JarDir.class.getClassLoader().loadClass(name.substring(0, name.length() - 6).replace("/", ".")).getModifiers();
if (Modifier.isPublic(value)) {
System.out.print(name.substring(10,name.length()-6) + "|");
}
}
}
System.out.println("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment