Calling Clojure From Java
While using Java APIs from Clojure is common due to Clojure’s embrace of the host platform, there are times when you’ll need to invoke Clojure directly from Java. For these cases, Clojure provides a Java API that can be used to directly access Clojure namespaces, vars, and functions.
The main entry point for the Clojure Java API is the clojure.java.api.Clojure class, which provides a few static methods for reading data, finding vars, and invoking unctions. With this handful of tools, you can invoke almost any aspect of Clojure.
For example, in a Java program, you can find the + function by using the var method of the Clojure class, which takes the namespace and name of a var and returns its value (in this case a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access