rendered paste bodypackage z.ex.loader;import java.io.File;import java.net.MalformedURLException;import java.net.URL;import java.net.URLClassLoader;public class Launcher { /** * @param args */ public static void main(String[] args) { try { // build your classpath of whatever you want File jar = new File("lib/repo.jar"); if (!jar.exists()) { System.err.println("no repo.jar"); return; } File test = new File("lib/test.jar"); if (!test.exists()) { System.err.println("no test.jar"); return; } System.out.println(Launcher.class.getName() + ": " + Launcher.class.getClassLoader()); URLClassLoader cl = new URLClassLoader(new URL[] { jar.toURL(), test.toURL() }); Class lt_class = cl.loadClass("z.ex.test.LoadedTest"); Runnable testMain = (Runnable) lt_class.newInstance(); testMain.run(); // this fails // Class.forName("z.ex.impl.RepoImpl"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } }}