Here you can find the source of getClassNamesByPkg(String pkg)
public static List<String> getClassNamesByPkg(String pkg)
//package com.java2s; //License from project: Apache License import java.io.File; import java.net.URL; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> getClassNamesByPkg(String pkg) { List<String> result = new ArrayList<>(); ClassLoader loader = Thread.currentThread().getContextClassLoader(); String packagePath = pkg.replace(".", "/"); URL url = loader.getResource(packagePath); File dir = new File(url.getPath()); for (File f : dir.listFiles()) { result.add(f.getName().replace(".class", "")); }/*from w w w.j ava 2 s . c o m*/ return result; } }