Code example for URLClassLoader

Methods: loadClass

0
    public Class loadClass(final String jarPath,
            final String testPkgName, final String testClassName)
            throws ClassNotFoundException, IOException { 
 
        URL urls[] = { new File(jarPath).getCanonicalFile().toURI().toURL() };
        URLClassLoader cl = new URLClassLoader(urls);
        Class testClass = cl.loadClass(testPkgName + "." + testClassName);
        Log.d("succeed in load jarred class: " + jarPath + "." + testPkgName
                + "." + testClassName);
 
        return testClass;
    } 
 
    /** 
     * Build test method. 
     * 
     * @param testClass The test class. 
     * @param testMethodName The method name. 
     * @return The test case. 
     */ 
    @SuppressWarnings("unchecked")