How can I start a Clojure REPL from my java application and provide some "predefined variables" (I´m a Clojure newbie, I guess there´s a better term for that)? In fact I already tried to make it work by coincidence... I started with clojure.main
and added an additional call to RT.var(). Is this the correct way to do it?
import clojure.lang.Symbol;
import clojure.lang.Var;
import clojure.lang.RT;
public class MyClojure {
final static private Symbol CLOJURE_MAIN = Symbol.intern("clojure.main");
final static private Var REQUIRE = RT.var("clojure.core", "require");
final static private Var MAIN = RT.var("clojure.main", "main");
// Provide some context, this is my custimisation...
@SuppressWarnings("unused")
final static private Var Test = RT.var("testme", "myvar", "This is the initial value");
public static void main(String[] args) throws Exception {
REQUIRE.invoke(CLOJURE_MAIN);
MAIN.applyTo(RT.seq(args));
}
}
EDIT: My application is not a web application. It´s a standalone desktop application that basically displays/edits a pojo data model. I now want to add support to expose the data model from the running application to a clojure repl. I would then be able to modify/inspect the data model thrugh both, the original application and the repl.