O'Reilly logo

Clojure Programming Cookbook by Nicolas Modrzyk, Makoto Hashimoto

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Calling Java methods and accessing Java objects from Clojure

Though the Clojure language looks quite different from Java, Clojure provides full access to Java. This enables Clojure to make use of huge Java assets very efficiently. In general, calling Java assets from Clojure is much simpler and results in less code than calling them from Java. Another big advantage is REPL, which makes programming fun and faster.

Getting ready

In this recipe, we don't use an external library, so the only necessary thing is to start REPL to run code.

How to do it...

We will learn how to instantiate objects, call instance and class methods, access fields and inner classes, and reference classes. Then, we will learn how to manipulate Java arrays.

Instantiating objects ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required