Here you can find the source of getClass(String parentPath, String className)
public static Class getClass(String parentPath, String className) throws Exception
//package com.java2s; //License from project: Apache License import java.io.File; import java.net.URI; import java.net.URL; import java.net.URLClassLoader; public class Main { public static Class getClass(String parentPath, String className) throws Exception { // ClassLoader c = new ClassLoader(new URL[]{}); File file = new File(parentPath); URI uri = file.toURI();// w ww .j av a 2 s . c o m URL url = uri.toURL(); URL[] urls = new URL[] { url }; // Create a new class loader with the directory ClassLoader loader = new URLClassLoader(urls, Thread.currentThread().getContextClassLoader()); Class cls = loader.loadClass(className); return cls; } }