Here you can find the source of loadClass(String dir, String classname)
public static Class loadClass(String dir, String classname)
//package com.java2s; //License from project: Open Source License import java.net.URL; import java.net.URLClassLoader; public class Main { public static Class loadClass(String dir, String classname) { try {//w w w . j ava 2s . c om URL[] urls = new URL[] { new URL("file:" + dir + "/") }; ClassLoader loader = URLClassLoader.newInstance(urls); return loader.loadClass(classname); } catch (Exception e) { e.printStackTrace(); } return null; } }