I need to compile some clojure file into java bytecode files, store them on the disk, so I would be able to load/execute them later.
I tried the following:
RT.load("clojure/core");
RT.init();
String clazz = "(ns org.rogach.avalanche.build (:gen-class)) (defn -doStuff [] (println 1))";
Compiler.load(new StringReader(clazz));
Compiler.load(new StringReader("(compile 'org.rogach.avalanche.build)"));
But it fails:
Exception in thread "main" java.io.FileNotFoundException:
Could not locate org/rogach/avalanche/build__init.class or org/rogach/avalanche/build.clj on classpath
To be fair, exactly the same thing happens if I execute that code from clojure REPL directly.
Also, this approach doesn't let me to specify output directory for class files, which also important.
How can I compile that clojure code to classfiles?
clojure.coreis almost certainly what causes the startup time, not loading and compiling your config file.