Ciao a tutti!
Sto cercando di capire come si fa a recuperare una classe, ovvero un'istanza di tipo Class, da un file .class.
Non riesco a capire perchè, in questo programma di prova che ho scritto in cui cerco di recuperare un'istanza di tipo Class da un file .class (che appartiene al progetto open source "Checkstyle"), alla riga in cui utilizzo il metodo Class.forName() ottengo una ClassNotFoundException. Ecco mio il codice:

codice:
import java.io.*;
import java.net.*;

/*
 * Just a test: get the Class from this .class file:
 * C:\Users\Federico\Downloads\checkstyle-4.4\checkstyle-4.4\checkstyle-4.4\com\puppycrawl\tools\checkstyle\api\Check.class
 * 
 * The source code of that class, Check.java, reports this package:
 * com.puppycrawl.tools.checkstyle.api
 * and the class file is infact in this path from the project's root directory:
 * /com/puppycrawl/tools/checkstyle/api/Check.class
 * 
 * So the fully qualified name for that class should be:
 * com.puppycrawl.tools.checkstyle.api.Check
 */
public class ListMethodsSimple {
	public static void main(String[] args) {
		String dirPath = "C:\\Users\\Federico\\Downloads\\checkstyle-4.4\\checkstyle-4.4\\checkstyle-4.4\\com\\puppycrawl\\tools\\checkstyle\\api\\";
		File parentDirectory = new File(dirPath);
		
		try {
			URL url = parentDirectory.toURI().toURL();
			URLClassLoader classLoader = URLClassLoader.newInstance(new URL[] { url });
			String fullyQualifiedName = "com.puppycrawl.tools.checkstyle.api.Check";
			
			Class theClass = Class.forName(fullyQualifiedName, true, classLoader); // ClassNotFoundException
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
Perchè ottengo la ClassNotFoundException? Sapreste dirmi dov'è che sbaglio?
Grazie in anticipo per il vostro aiuto!