четверг, 12 июня 2014 г.

call clojure code from java


Since clojure 1.6 there is no more special dances inside clojure code: special declarations or wrappers or something else. it is possible call clojure code from jar file like this. Clojure code (jar file) and clojure-1.6.jar should be in a class-path.

import clojure.java.api.Clojure;
import clojure.lang.IFn;

        IFn require = Clojure.var("clojure.core", "require");
        require.invoke(Clojure.read("my-clj-project.core"));

        IFn myf0 = Clojure.var("my-clj-project.core", "my-clojure-func0");
        myf0.invoke();

or  myf0.invoke(param1, param2);

Комментариев нет:

Отправить комментарий