Skip to content

Instantly share code, notes, and snippets.

@perry14
Created November 7, 2019 01:15
Show Gist options
  • Select an option

  • Save perry14/2eaabfa47cfd990691131417c1dfa5b1 to your computer and use it in GitHub Desktop.

Select an option

Save perry14/2eaabfa47cfd990691131417c1dfa5b1 to your computer and use it in GitHub Desktop.
获取jar包中的class名
import java.io.IOException;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
public class Main {
public static void main(String[] args) throws IOException {
// 项目中jar包所在物理路径
String jarName = "/Users/admin/src/test.jar";
JarFile jarFile = new JarFile(jarName);
Enumeration<JarEntry> entrys = jarFile.entries();
while (entrys.hasMoreElements()) {
JarEntry jarEntry = entrys.nextElement();
System.out.println(jarEntry.getName());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment