I have a Clojure project, and I\'m using leiningen. I\'m also using tools.namespace to reload Clojure code while running a REPL. If I want to include Java source in the project,
Pure java way
public class MyClassFactory {
public static MyClass newInstance() {
URLClassLoader cl =
new URLClassLoader(new URL[] {getMyClassPath()}) {
public Class loadClass(String name) {
if ("MyClass".equals(name))
return findClass(name);
return super.loadClass(name);
}
};
return (MyClass) cl.loadClass("MyClass").newInstance();
}
}
by this way you can lead the class loader to load classes programmatically.
References