Using the Cloudinary APIs from Clojure
There are a few advantages to Clojure running on the JVM. One of the biggest is that we can use any Java library in our Clojure projects. Two other is that we can take advantage of all the awesome server infrastructure stuff that exist for Java services and that we can build a .jar file that runs everywhere with a Java Runtime installed.
Most of the time you want to use something that is packaged to be nice to use in Clojure. But you don’t always have that option, and it is really nice to just import some Java libraries when that occurs. The way you do this is that you add the dependency to lean like any other dependency. Lein will look in both Clojars and Maven for packages you add. And then you load the classes or packages you need using “(:import)” instead of “(:require)” in your code. Now you can just do something like (.methodName className) or (.methodName objectName). I’m going to write more about this in the future.
I have put together this GitHub repo, with some code showing the basics of interacting with the Cloudinary API’s from Clojure using the Java SDK.