Here you can find the source of getClasses(String pckgname)
@SuppressWarnings("rawtypes") public static List<Class> getClasses(String pckgname) throws ClassNotFoundException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.net.URL; import java.util.ArrayList; import java.util.List; public class Main { @SuppressWarnings("rawtypes") public static List<Class> getClasses(String pckgname) throws ClassNotFoundException { List<Class> classes = new ArrayList<Class>(); ClassLoader cld = Thread.currentThread().getContextClassLoader(); String path = '/' + pckgname.replace('.', '/'); URL resource = cld.getResource(path); File directory = new File(resource.getFile()); if (directory.exists()) { String[] files = directory.list(); for (int i = 0; i < files.length; i++) { if (files[i].endsWith(".class")) { classes.add(Class.forName(pckgname + '.' + files[i].substring(0, files[i].length() - 6))); }/*from www . java2 s . c o m*/ } } return classes; } }