Here you can find the source of getClassNamesFromPackage(String packageName)
public static ArrayList<String> getClassNamesFromPackage(String packageName) throws IOException, URISyntaxException, ClassNotFoundException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; public class Main { public static ArrayList<String> getClassNamesFromPackage(String packageName) throws IOException, URISyntaxException, ClassNotFoundException { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ArrayList<String> names = new ArrayList<String>(); packageName = packageName.replace(".", "/"); URL packageURL = classLoader.getResource(packageName); URI uri = new URI(packageURL.toString()); File folder = new File(uri.getPath()); File[] files = folder.listFiles(); for (File file : files) { String name = file.getName(); name = name.substring(0, name.lastIndexOf('.')); // remove ".class" names.add(name);//from ww w . j a v a 2 s .c om } return names; } }