一、前言
通过java.net.URLClassLoader定义JarLoader加载器类,对指定Properties配置中追加加载jar包的路径地址,详情参见代码示例。
二、代码示例
1. JarLoader类import java.net.URL;@b@import java.net.URLClassLoader;@b@import java.util.Properties;@b@@b@public class JarLoader {@b@@b@private static String CLASS_PATH = JarLoader.class.getResource("/").getPath();@b@private static String CLASS_LIB_PATH = CLASS_PATH + "lib/";@b@private static String DEFAULT_FILE = CLASS_PATH + "jar.config.properties";@b@@b@public static void load()@b@ throws Exception@b@ {@b@ Properties prop = PropertiesReader.read(DEFAULT_FILE);@b@ String jarName = prop.getProperty("account.jar");@b@ loadJar(CLASS_LIB_PATH + jarName);F@b@ }@b@@b@public static void loadJar(String jarFile