List of utility methods to do ClassPath Get
Class | getClassFromLibs(String className, List get Class From Libs ClassLoader clr = createClassLoader(libs, useSystemClassPath);
return (Class<T>) clr.loadClass(className);
|
Set | getClassLoaderClasspath(ClassLoader loader) get Class Loader Classpath LinkedHashSet<URL> jars = new LinkedHashSet<URL>(); getClassLoaderClasspath(loader, jars); return jars; |
String | getClassPath() get Class Path String classpath = ""; URL resource = Thread.currentThread().getContextClassLoader().getResource(""); if (resource != null) { classpath = resource.getPath(); return classpath; |
List | getClasspath() get Classpath return Arrays.asList(getClassLoader().getURLs());
|
String | getClasspath() Returns the classpath, prefaced by the string 'Classpath:\n'. StringBuilder sb = new StringBuilder("Classpath:\n"); ClassLoader cl = ClassLoader.getSystemClassLoader(); URL[] urls = ((URLClassLoader) cl).getURLs(); for (URL url : urls) { sb.append(url.getFile()).append("\n"); return sb.toString(); |
String | getClassPath() get Class Path StringBuffer buf = new StringBuffer(); ClassLoader cl = ClassLoader.getSystemClassLoader(); URL[] urls = ((URLClassLoader) cl).getURLs(); for (URL url : urls) { if (buf.length() > 0) buf.append(";"); buf.append(url.getFile()); return buf.toString(); |
List | getClasspath() get Classpath ArrayList<URL> classpath = new ArrayList<URL>(); ClassLoader cl = ClassLoader.getSystemClassLoader(); URL[] urls = ((URLClassLoader) cl).getURLs(); for (URL url : urls) { classpath.add(url); return classpath; |
URL[] | getClasspath() Get the current classpath. URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader(); Class<?> sysclass = URLClassLoader.class; try { Method method = sysclass.getDeclaredMethod("getURLs", noparams); method.setAccessible(true); return (URL[]) method.invoke(sysloader, new Object[0]); } catch (Throwable t) { return new URL[0]; ... |
List | getClasspath() get Classpath Function<URL, URI> func = new Function<URL, URI>() { @Override public URI apply(URL f) { try { return f.toURI(); } catch (URISyntaxException ex) { throw new RuntimeException(ex); }; return Lists.transform(Arrays.asList(getClassLoader().getURLs()), func); |
URL | getClassPath(Class> c) get Class Path String classFile = c.getName().replace('.', '/') + ".class"; URL url = c.getClassLoader().getResource(classFile); if (url == null) return null; if (url.getProtocol().equals("jar")) { String urlFile = url.getFile(); int i = urlFile.indexOf("!"); if (i > 0) { ... |