将Jar添加到类路径
//package com.nowjava; /**来自 n o w j a v a . c o m - 时 代 Java**/ import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; public class Main { public static void addJarToClassPath(URL[] urls) throws Exception { URLClassLoader sysloader = (URLClassLoader) ClassLoader .getSystemClassLoader(); java.lang.Class<URLClassLoader> sysclass = URLClassLoader.class; java.lang.Class<?>[] parameters = new java.lang.Class<?>[] { URL.class }; try { java.lang.reflect.Method method = sysclass.getDeclaredMethod(// 来 自 n o w j a v a . c o m - 时代Java "addURL", parameters); method.setAccessible(true); for (URL url : urls) { method.invoke(sysloader, new Object[] { url }); } } catch (Throwable t) { t.prin