JavaLibrary { public static Class<?> classFromClasspath(URL classpath, String qualifiedName) { List<Class<?>> classes = classesFromClasspath(new URL[]{classpath}, asList(qualifiedName)); if (classes.isEmpty()) { return null; } return classes.iterator().next(); }  static String asClasspath(URL[] urls); static String[] asFilePath(URL[] urls); static String simpleClassName(String qualifiedClassName); static String packageName(String qualifiedClassName); static String systemClasspath(); static URL[] systemClasspathURLs(); static void extendSystemClasspathWith(URL[] classpaths); static URL[] extendClasspathWith(String classpath, URL[] destination); static URL[] classpathFrom(String classpath); static void setClasspath(String newClasspath); static void extendSystemClassLoaderClasspathWith(URL[] classpaths); static void extendClassLoaderClasspathWith(URLClassLoader classLoader, URL[] classpaths); static Class<?> classFromClasspath(URL classpath, String qualifiedName); static List<Class<?>> classesFromClasspath(URL[] classpath, Collection<String> qualifiedNames); static List<Class<?>> loadedClassesFrom(ClassLoader classLoader, Collection<String> qualifiedNames); static void close(URLClassLoader loader); static Character classpathSeparator(); static Character folderPathSeparator(); static String lineSeparator();  }
@Test public void loadingClassFromClasspath() throws Exception { String qualifiedName = "xxl.java.library.HelloWorld"; URL classpath = FileLibrary.resource("/helloWorld/HelloWorld.jar"); Class<?> helloWorldClass = classFromClasspath(classpath, qualifiedName); assertTrue(helloWorldClass != null); Method greet = helloWorldClass.getMethod("greet"); assertEquals("Hello, world!", greet.invoke(helloWorldClass.newInstance())); }