Java examples for Reflection:Class
get Url Class Loader
//package com.java2s; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; public class Main { public static void main(String[] argv) throws Exception { String directoryPath = "java2s.com"; System.out.println(getUrlClassLoader(directoryPath)); }//from w w w.j av a 2s . c om public static URLClassLoader getUrlClassLoader(String directoryPath) { // directoryPath File f = new File(directoryPath); URL url; URL[] urls = null; URLClassLoader urlClassLoader = null; try { url = f.toURI().toURL(); urls = new URL[] { url }; urlClassLoader = new URLClassLoader(urls); } catch (MalformedURLException e) { e.printStackTrace(); } return urlClassLoader; } }