periodical I'm getting jars, which contain Java-Applications. Now I want to search these jars for more jars and add them to my classpath using a Java Standalone program. After that I want to get the included classes using Class.forName and analyze them by reflection.

I already managed it to search the jars for classes. But when I tried to get the classes by Class.forName, I got errors. The cause was the dependencies of some classes via imports. I haven't had the dependencies in my classpath, because I don't know these dependencies at runtime.

That's why I want to put all dependend jars into my classpath. Currently I get all jars that I need via a for loop as strings (complete path and jar name).

Now what I have to do to put these jars within my for loop into my classpath at runtime? I'd like to get the whole jars, not only a few classes from within these jars.