Here you can find the source of addToClassPath(File file)
public static void addToClassPath(File file)
//package com.java2s; //License from project: Apache License import java.io.File; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; public class Main { public static void addToClassPath(File file) { if (!file.exists()) { throw new RuntimeException(file + " not found"); }// ww w. j a v a 2 s.c om try { Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[] { URL.class }); method.setAccessible(true); method.invoke(ClassLoader.getSystemClassLoader(), new Object[] { file.toURI().toURL() }); } catch (Exception e) { throw new RuntimeException("Error adding JRI.jar to classpath"); } } }