package net.sourceforge.javautil.classloader.util;
import java.util.List;
import net.sourceforge.javautil.classloader.impl.ClassInfo;
import net.sourceforge.javautil.classloader.impl.ClassSearchInfo;
import net.sourceforge.javautil.classloader.source.ClassSource;
import net.sourceforge.javautil.classloader.source.LibDirectoryClassSource;
import net.sourceforge.javautil.common.io.impl.SystemDirectory;
/**
* This will allow one to search for a class using all the libraries found in a particular directory recursively.
*
* @author elponderador
* @author $Author$
* @version $Id$
*/
public class ClassSearch {
/**
* The first argument should be the directory to search in.
* The second argument should be the class name to search for.
*
* @param args Command line arguments
*/
public static void main (String[] args) {
if (args.length != 2) {
System.err.println("Please provide the library directory and the class name to search for.");
} else {
System.out.println("Searching for " + args[1] + " in " + args[0]);
LibDirectoryClassSource lib = new LibDirectoryClassSource(new SystemDirectory(args[0]), true);
List<ClassSource> sources = lib.getAllNonCompositeSources();
for (ClassSource source : sources) {
try {
ClassInfo info = source.getClassInfo(new ClassSearchInfo(args[1]));
System.out.println("Found in " + info.getSource());
} catch (ClassNotFoundException e) {}
}
}
}
}