List of utility methods to do Jar File Find
List | findAllPluginJars0(final File pluginPath) find All Plugin Jars final List<URL> jars = new ArrayList<URL>(); for (final File entry : pluginPath.listFiles()) { if (entry.isDirectory()) { jars.addAll(findAllPluginJars0(entry)); } else if (entry.isFile() && entry.getName().toLowerCase().endsWith(".jar")) { jars.add(entry.toURI().toURL()); return jars; |
URL | findClassJar(final Class> aClass) The retrieves the URL of the Jar file containing the given class return aClass.getResource('/' + aClass.getName().replace('.', '/') + ".class"); |
String | findContainingJar(@SuppressWarnings("rawtypes") Class my_class, ClassLoader loader) find Containing Jar String class_file = my_class.getName().replaceAll("\\.", "/") + ".class"; return findContainingJar(class_file, loader); |
String | findContainingJar(Class my_class) Find a jar that contains a class of the same name, if any. ClassLoader loader = my_class.getClassLoader(); String class_file = my_class.getName().replaceAll("\\.", "/") + ".class"; try { for (Enumeration itr = loader.getResources(class_file); itr.hasMoreElements();) { URL url = (URL) itr.nextElement(); if ("jar".equals(url.getProtocol())) { String toReturn = url.getPath(); if (toReturn.startsWith("file:")) { ... |
String | findContainingJar(Class> clazz) find Containing Jar ClassLoader loader = clazz.getClassLoader(); String classFile = clazz.getName().replaceAll("\\.", "/") + ".class"; try { for (final Enumeration<URL> itr = loader.getResources(classFile); itr.hasMoreElements();) { final URL url = itr.nextElement(); if ("jar".equals(url.getProtocol())) { String path = url.getPath(); if (path.startsWith("file:")) { ... |
String | findContainingJar(Class> clazz) find Containing Jar return findContainingJar(clazz, null);
|
String | findContainingJar(Class> myClass, Map Find a jar that contains a class of the same name, if any. ClassLoader loader = myClass.getClassLoader(); String classFile = myClass.getName().replaceAll("\\.", "/") + ".class"; for (Enumeration<URL> itr = loader.getResources(classFile); itr.hasMoreElements();) { URL url = itr.nextElement(); if ("jar".equals(url.getProtocol())) { String toReturn = url.getPath(); if (toReturn.startsWith("file:")) { toReturn = toReturn.substring("file:".length()); ... |
File | findContainingJar(ClassLoader classLoader, String resourceName) find Containing Jar File jarFile; URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName); if ("jar".equals(url.getProtocol())) { String path = url.getPath(); int index = path.indexOf("!/"); if (index >= 0) { try { String jarPath = path.substring(0, index); ... |
String | findJar(Class> klass) find Jar String className = klass.getName();
ClassLoader cl = klass.getClassLoader();
return findJar(className, cl);
|
String | findJar(Class> my_class) find Jar ClassLoader loader = my_class.getClassLoader(); String class_file = my_class.getName().replaceAll("\\.", "/") + ".class"; try { for (Enumeration<?> itr = loader.getResources(class_file); itr.hasMoreElements();) { URL url = (URL) itr.nextElement(); if ("jar".equals(url.getProtocol())) { String toReturn = url.getPath(); if (toReturn.startsWith("file:")) { ... |