List of utility methods to do ClassPath Add
void | addToClasspath(File f) Adds a given file to the classpath. try { Method addURL = URLClassLoader.class.getDeclaredMethod("addURL", new Class[] { URL.class }); addURL.setAccessible(true); URL url = f.toURI().toURL(); ClassLoader cl = ClassLoader.getSystemClassLoader(); addURL.invoke(cl, new Object[] { url }); } catch (NoSuchMethodException | SecurityException | MalformedURLException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { ... |
void | addToClassPath(File file) add To Class Path if (!file.exists()) { throw new RuntimeException(file + " not found"); try { Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[] { URL.class }); method.setAccessible(true); method.invoke(ClassLoader.getSystemClassLoader(), new Object[] { file.toURI().toURL() }); } catch (Exception e) { ... |
boolean | addToClasspath(File file) Adds the specified file to the classpath dynamically if (!file.exists()) { return false; URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader(); Class<URLClassLoader> sysclass = URLClassLoader.class; try { Method method = sysclass.getDeclaredMethod("addURL", new Class[] { URL.class }); method.setAccessible(true); ... |
void | addToClassPath(String s) add To Class Path File f = new File(s);
addToClassPath(f);
|
void | addToClassPath(Vector cpV, String dir) Add all the jar files in a dir to the classpath, represented as a Vector of URLs. try { String cpComp[] = getFilesByExt(dir, ".jar"); if (cpComp != null) { int jarCount = cpComp.length; for (int i = 0; i < jarCount; i++) { URL url = getURL(dir, cpComp[i]); if (url != null) cpV.addElement(url); ... |