@Test public void appendToClassPath() { assertTrue(JVMUtil.appendToClassPath(classpath + File.separator + "lib/test1.jar")); assertFalse(JVMUtil.appendToClassPath(null)); assertFalse(JVMUtil.appendToClassPath("")); assertFalse(JVMUtil.appendToClassPath("impossible exist! ")); assertFalse(JVMUtil.appendToClassPath(classpath + File.separator + "lib/notexist.jar")); }
public static boolean appendToClassPath(String name) { if (!FileUtil.exist(name)) { return false; } try { ClassLoader clsLoader = ClassLoader.getSystemClassLoader(); Method appendToClassPathMethod = clsLoader.getClass().getDeclaredMethod("appendToClassPathForInstrumentation", String.class); if (null != appendToClassPathMethod) { appendToClassPathMethod.setAccessible(true); appendToClassPathMethod.invoke(clsLoader, name); } return true; } catch (Exception e) { throw ExceptionUtil.toRuntimeException(e); } }
JVMUtil { public static boolean appendToClassPath(String name) { if (!FileUtil.exist(name)) { return false; } try { ClassLoader clsLoader = ClassLoader.getSystemClassLoader(); Method appendToClassPathMethod = clsLoader.getClass().getDeclaredMethod("appendToClassPathForInstrumentation", String.class); if (null != appendToClassPathMethod) { appendToClassPathMethod.setAccessible(true); appendToClassPathMethod.invoke(clsLoader, name); } return true; } catch (Exception e) { throw ExceptionUtil.toRuntimeException(e); } } }
JVMUtil { public static boolean appendToClassPath(String name) { if (!FileUtil.exist(name)) { return false; } try { ClassLoader clsLoader = ClassLoader.getSystemClassLoader(); Method appendToClassPathMethod = clsLoader.getClass().getDeclaredMethod("appendToClassPathForInstrumentation", String.class); if (null != appendToClassPathMethod) { appendToClassPathMethod.setAccessible(true); appendToClassPathMethod.invoke(clsLoader, name); } return true; } catch (Exception e) { throw ExceptionUtil.toRuntimeException(e); } }  }
JVMUtil { public static boolean appendToClassPath(String name) { if (!FileUtil.exist(name)) { return false; } try { ClassLoader clsLoader = ClassLoader.getSystemClassLoader(); Method appendToClassPathMethod = clsLoader.getClass().getDeclaredMethod("appendToClassPathForInstrumentation", String.class); if (null != appendToClassPathMethod) { appendToClassPathMethod.setAccessible(true); appendToClassPathMethod.invoke(clsLoader, name); } return true; } catch (Exception e) { throw ExceptionUtil.toRuntimeException(e); } }  static boolean appendToClassPath(String name); static String[] addAllJarsToClassPath(String dirName); static Manifest getManifest(File classpathItem); static File[] getClasspath(); static File[] getClasspath(ClassLoader classLoader); static final JavaRuntimeInfo getJavaRuntimeInfo(); }
JVMUtil { public static boolean appendToClassPath(String name) { if (!FileUtil.exist(name)) { return false; } try { ClassLoader clsLoader = ClassLoader.getSystemClassLoader(); Method appendToClassPathMethod = clsLoader.getClass().getDeclaredMethod("appendToClassPathForInstrumentation", String.class); if (null != appendToClassPathMethod) { appendToClassPathMethod.setAccessible(true); appendToClassPathMethod.invoke(clsLoader, name); } return true; } catch (Exception e) { throw ExceptionUtil.toRuntimeException(e); } }  static boolean appendToClassPath(String name); static String[] addAllJarsToClassPath(String dirName); static Manifest getManifest(File classpathItem); static File[] getClasspath(); static File[] getClasspath(ClassLoader classLoader); static final JavaRuntimeInfo getJavaRuntimeInfo();  }