clojure-site icon indicating copy to clipboard operation
clojure-site copied to clipboard

Guide/faq for AOT main shim

Open puredanger opened this issue 9 years ago • 1 comments

"I wish there was more "best practice" out there about having a shim for -main and dynamically loading the rest"

puredanger avatar Sep 19 '16 17:09 puredanger

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());
        }
    }
}

danielcompton avatar Sep 19 '16 20:09 danielcompton