Monday 15 July 2013

Is it possible to compile a string of Clojure code to classes from java? -


I need to compile some close-up files in Java Bitcode files, to store them on disk, so I may be able to load / load.

Perform them later.

I tried the following:

  RT.load ("Closer / Core"); RT.init (); String clause = "(ns org.rogach.avalanche.build (gen-class)) (defn -doStuff [] (println 1)); Compiler load (new stringreader (clause)); Compiler load (new string reader ("(compile 'org.rogach.avalanche.build)"));   

but it fails:

  Exceptions to thread "main" java.io.FileNotFoundException: org / rogach / avalanche / build__init.class could be found for ORG on Classpath / rogach / avalanche / build.clj   

If appropriate, do exactly what happens if I execute code directly from closure Arpielel.

In addition to this, this approach does not allow me to specify the output directory for class files, which is also important.

How do I collect that closing code into a class file?

I strongly suspect that: not directly.

Aoti compilation unit namespace, and compile the function name in a file I think it is necessary to write in the correct relative path to closure files to compile function to find the appropriate namespaces.

No comments:

Post a Comment