Search code examples
clojurekotlinclojure-java-interopkotlin-interop

How to run Clojure in Kotlin?


Is it possible to run clojure in kotlin? More specific in spring?

I have made scrapers in clojure and I want to use them on a web application written in kotlin. How does that look like in kotlin? The code..


Solution

  • I would suggest using the clojure.java.api.Clojure class, as documented in the Java interop section of Clojure reference documentation under the heading Calling Clojure From Java.

    A Java example:

    import clojure.java.api.Clojure;
    import clojure.lang.IFn;
    
    // this part taken from the reference page linked above:
    IFn plus = Clojure.var("clojure.core", "+");
    plus.invoke(1, 2);