How can I dynamically load a jar file and list classes which is in it?
Here is code for listing classes in jar:
import java.io.IOException;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
public class JarList {
public static void main(String args[]) throws IOException {
if (args.length > 0) {
JarFile jarFile = new JarFile(args[0]);
Enumeration allEntries = jarFile.entries();
while (allEntries.hasMoreElements()) {
JarEntry entry = (JarEntry) allEntries.nextElement();
String name = entry.getName();
System.out.println(name);
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With