how to print all package in java

Solutions on MaxInterview for how to print all package in java by the best coders in the world

showing results for - "how to print all package in java"
Gabriele
04 Aug 2016
1final ClassLoader loader = Thread.currentThread().getContextClassLoader();
2
3for (final ClassPath.ClassInfo info : ClassPath.from(loader).getTopLevelClasses()) {
4  if (info.getName().startsWith("my.package.")) {
5    final Class<?> clazz = info.load();
6    // do something with your clazz
7  }
8}
9