I want to add a jar File to my project\'s classpath dynamically using java code if it is possible , I want to use external jar files and load their classes the execute them as B
URLClassLoader child = new URLClassLoader (myJar.toURL(), this.getClass().getClassLoader());
Class classToLoad = Class.forName ("com.MyClass", true, child);
Method method = classToLoad.getDeclaredMethod ("myMethod");
Object instance = classToLoad.newInstance ();
Object result = method.invoke (instance);
Source: https://stackoverflow.com/a/60775/1360074