clojure-site
clojure-site copied to clipboard
Guide/faq for AOT main shim
"I wish there was more "best practice" out there about having a shim for -main and dynamically loading the rest"
Not sure how idiomatic it is (or if I've misunderstood the question), but here's what we use:
package our.cool_app;
import clojure.java.api.Clojure;
import clojure.lang.IFn;
public class Main {
public static void main(String[] args) {
try {
IFn require = Clojure.var("clojure.core", "require");
require.invoke(Clojure.read("our.cool_app.core"));
Clojure.var("our.cool_app.core", "start!").invoke();
}
catch (Throwable e) {
System.out.println(e.getMessage());
}
}
}